This error is due to a change in your data model, whether you modified it or added components to your solution, or if applicable, the database underwent changes in its structure and the changes do not match the definitions of Entity Framework.
To solve this you must identify the class where your database is initialized, if your data model is called DataContext
, then you can find it as DataContextInitializer
, and then implement from System.Data.Entity.DropCreateDatabaseIfModelChanges
public class DataContextInitializer : System.Data.Entity.DropCreateDatabaseIfModelChanges<DataContext>
{
protected override void Seed(DataContext context)
{
SqlConnection.ClearAllPools();
context.Database.CreateIfNotExists();
System.Data.Entity.Database.SetInitializer(new NullDatabaseInitializer<DataContext>());
}
}
With this, if your data model has undergone any changes, it would be forced to recreate the database to be able to maintain objects.