【发布时间】:2016-02-27 20:53:07
【问题描述】:
我和我的同事正在开发同一个项目,这是一个使用 EF 6 Code First 方法的小型图书馆。为了使数据库保持最新,我们正在使用迁移。昨天我合并了我同事的分支。该分支包含两个由Add-Migration [MigrationName] 命令创建的新迁移。
现在,当我尝试运行 Update-Database 命令时出现错误
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.
我尝试重新运行Add-Migration 命令以查看模型中的“新”内容。 EF 为我同事迁移中所做的所有更改创建了一个巨大的迁移。看来 EF 没有看到来自合并的迁移
【问题讨论】:
-
您需要获取您同事的迁移名称并执行
Add-Migration [MigrationName1]然后第二个来更新我认为的元数据 -
感谢您的建议。我已经尝试过这种方法。例如,我从同事那里获得了 AddContractTables 迁移,并按照您的建议运行
Add-Migration AddContractTables。 EF 已创建名为 AddContractTables1 的新迁移
标签: git entity-framework code-first entity-framework-migrations