Entity Framework model change error

  1. If you already deployed your application or you don't want remove data from database you must read about Code First Migrations. Here you have a link: http://msdn.microsoft.com/en-us/library/hh770484(v=vs.103).aspx

  2. If you can delete database just do it. EF will create new database that match your model.

  3. You can also disable creating/updating database structure by invoking the following code:

    Database.SetInitializer<MyDbContext>(null);
    

If you delete the __MigrationHistory table in SQL Server it should fix it.


I used database first to create a project after I had changed my database context and solved my problem:

Database.SetInitializer<Models.YourDbContext>(null);

Don't forget to handle the DbUpdateException