Lose EF Code First Migration when working on different TFS branches?

An EF migration step contains a metadata file, that has a signature of the model that is the result of the migration step. The problem when merging is that the signature of the migration done in branch B doesn’t include the stuff done in the migration in branch A. As long as the migrations are in the branches, this is correct. When merging it becomes wrong.

To remedy it, you have to regenerate the meta-data of the latter migration with

add-migration MyMigrationName

Running add-migration on an existing migration without the -force parameter will regenerate just the metadata.

I wrote an in depth walk-through of a merging scenario in the EF Migrations and a Merge Conflict post on my blog.

Leave a Comment