I am trying to use Code First with Migrations. Even though there are no current changes to my model, I\'m getting an exception. When I add a migration, the up and down are e
I am not sure if you found the answer to your problem, but this other answer I found here actually did it for me: Entity Framework model change error
I actually ended up deleting the __MigrationHistory
table in SQL Server which I didn't know it was being created automatically.
The article also talks about the option to not generate it I think by using this instruction: Database.SetInitializer<MyDbContext>(null);
but I have not used it, so I am not sure if it works like that
I bet your data context is not hooking up the connection string.
Check if it's not initialized with a localdb (something like (localdb)\v11.0
) and not working with that when you might think it's set to something else.
My issue ended up being a conflict between Automatic Migrations being enabled and the initializer MigrateDatabaseToLatestVersion as described here.
This worked for me.
Go to Package Manager Console and Run - Update-Database -force