在不同的TFS分公司工作时,失去EF $ C C第一次迁徙$?不同、分公司、工作、EF

2023-09-04 01:31:21 作者:回眸一笑

我们正在使用TFS,并有不同的分支,为开发。

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

在支路A我们做了一个迁移到更改列尺寸

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

在支路B我们做了迁移来添加新的表。这个分支没有按不知道该分支的修改!!

in the branch B we made a migration to add a new table. This branch doesn not know about the branch A modification !!

这两个修改合并到主分支。

both modification are merged to the main branch.

当我做一个更新的数据库,它的2迁移,但在最后告诉我有挂起的更改。如果我做一个外接迁移,它创建了相同第一迁移(分支A)。

When I do an update database, it does the 2 migration but at the end tells me there is pending changes. If I do an Add-Migration, it creates the same as the 1st migration (in branch A).

无法更新数据库,以目前的模式匹配,因为有挂起       变化,自动迁移被禁用。无论是写挂起模式       更改为code为基础的迁移或启用自动迁移。组       DbMigrationsConfiguration.AutomaticMigrationsEnabled为true启用自动       迁移。       您可以使用Add-迁移命令写入挂起模式变为       code为基础的迁移。

已经参加工作的你还会去接家里人给你的压岁钱吗

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.

是不是因为事情是在我的最后一次迁移的属性Target德IMigrationMetadata的内容缺失,因为它不知道一日一?

Is it because something is missing in the content of the property Target de IMigrationMetadata of my last migration since it didn't know about the 1st one ?

是否有可能来处理移民在不同的TFS分支?

Is it possible to handle migrations in different TFS branches?

推荐答案

这是EF迁移步骤包含的元数据文件,具有模型是迁移步​​骤的结果的一个签名。合并时的问题是,在支路B进行迁移的签名不包括分支A.只要移民在枝头,这是正确的,在迁移完成的东西。当合并成为错误的。

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

运行添加迁移在现有的迁移,而不 -force 参数将产生仅仅元数据。

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

我在写了深入的步行通过合并方案的EF迁移和合并冲突发表在我的博客。