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