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

前端 未结 3 1360
攒了一身酷
攒了一身酷 2020-12-23 09:44

We are using TFS and have different branches for our Dev.

  1. in the branch A we made a migration to change a column size

  2. in the branch B we mad

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 10:40

    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.

提交回复
热议问题