0

I have a problem, the program launches but it crashes with an exception : Message=Invalid object name 'dbo.Entity1Set'. What happens ?

class Program
{
    static void Main(string[] args)
    { 
        Model1Container db = new Model1Container();
        db.Database.CreateIfNotExists();
        Personne ps = new Personne();
        ps.Nom = "Loup";
        ps.Prénom = "Julien";
        db.PersonneSet.Add(ps);
        db.GetValidationErrors();
        db.SaveChanges(); //Exception ???
        Console.ReadKey();
    }
}

I don't know how and where to add "CreateDatabaseIfNotExists" in my code...

3
  • Possible duplicate of Entity Framework Exception: Invalid object name. Please make sure you've set CreateDatabaseIfNotExists
    – paulsm4
    Commented Jan 18, 2016 at 23:27
  • ok but I don't know where and how to add CreateDatabaseIfNotExists in my code, exactly
    – John Mary
    Commented Jan 18, 2016 at 23:34
  • Any idea to help me ? If the problem is to ad d "CreateDatabaseIfNotExists", I edited my first message
    – John Mary
    Commented Jan 19, 2016 at 7:56

0

Browse other questions tagged or ask your own question.