When working on various TFS branches, do you lose EF Code First Migration?

.net coldfusion ef-code-first ef-migrations entity-framework


We use TFS and have many development branches.

  1. We created a migration on branch A to alter the column size.

  2. We created a migration in branch B to add a new table. This branch is unaware of the branch. An adjustment!

  3. Both changes have been added to the main branch.

When I update my database, it does two migrations, but in the end it notifies me that there are still pending changes. The first migration is duplicated if I do an Add-Migration (in branch A).

Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration. You can use the Add-Migration command to write the pending model changes to a code-based migration.

Is this because my most recent migration's property Target de IMigrationMetadata is lacking anything since it was unaware of my first migration?

Can you manage migrations across various TFS branches?

4/16/2012 9:46:27 AM

Accepted Answer

A metadata file with the model's signature, which is the end result of the migration step, is included in an EF migration step. The issue with merging is that the branch B migration's signature does not include the branch A migration's work. This is true as long as the migrations are in the branches. It gets incorrect upon merging.

You must rebuild the meta-data of the latter migration using to fix it.

add-migration MyMigrationName

Running add-migration a current migration without the-force just the metadata will be generated by argument.

In my blog article A merge dispute with EF Migrations, I detailed a walk-through of a merger situation.

5/1/2012 6:50:40 AM

Popular Answer

The model's current state is maintained by EF core in ***ModelSnapshot.cs. You usually don't need to do anything since it is merged, unless there is a problem.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow