I'm using EF 6.0.0 and .Net 4.5.
I face a very confusing problem. Me and one of my colleagues are working on the domain model section of our project on two different clients. The problem is:
1- Me and my colleagues start with the absolutely identical project and we are completely synced with the source control.
2- When I change the model for example add a property then Add-Migration FromA
then Update-Database
it works great. The generated code file contains just one command that is to add the column.
3- Meanwhile, after the db
is updated and just before I check in something to source control, my colleague adds another property and then Add-Migration FromA
then Update-Database
. And guess what? This generated code file has a command to drop the column I newly added!!!
I added another column using native Sql, and fortunately the column is not going to be deleted.
I deleted the __MigrationHistory
table and the remove column didn't get generated.
I turned off initializer Database.SetInitializer<MyContext>(null)
, no success.
So, my guess is that EF Migrations
compares current model with the last one stored in __MigrationHistory
table not the last local snapshot stored in .resx
file. Am I right? Any way to solve the problem?