无法添加迁移或更新数据库

时间:2017-06-12 14:57:25

标签: asp.net entity-framework-6 ef-migrations

我在ASP应用程序中使用Microsoft Identity表。处理Identity内容的ApplicationDbContext上下文位于我的主MyProject项目中。我的所有其他数据库内容都在项目MyContext中的MyProject.Data中。

启用迁移后,将使用所有Identity表创建初始迁移。然后我运行了Enable-Migrations -ContextProjectName MyProject.Data -StartUpProjectName MyProject.Data -ContextTypeName MyProject.Data.MyContext -ProjectName MyProject -Force,以便我可以从MyProject.Data项目中的应用程序表创建迁移。

现在,当我尝试Add-Migration时,我收到错误Unable to generate an explicit migration because the following explicit migrations are pending: [201705262027077_InitialCreate]. Apply the pending explicit migrations before attempting to generate a new explicit migration.

当我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. You can use the Add-Migration command to write the pending model changes to a code-based migration.

现在该错误消息告诉我添加迁移,我无法做到,因为第一个错误告诉我应用迁移。我不想启用自动迁移。我该如何解决这个问题?

0 个答案:

没有答案