添加迁移错误 [英] Errors on Add-Migration
问题描述
几周前,我在项目上启用了迁移,并在AspNetUsers表中添加了"ClientID"列.
A few weeks ago I enabled migration on my project and added a column 'ClientID' to the AspNetUsers table.
现在我正尝试添加另一列:名称".
Now I'm trying to add another column: "Name".
我在程序包管理器控制台中运行了此命令:
I ran this command in the Package Manager Console:
PM> Add-Migration "Name"
我收到以下错误:
由于以下原因,无法生成显式迁移显式迁移尚在等待中:[20161081751088_InitialCreate,20161091825212_ClientID].应用待处理的显式迁移尝试生成新的显式迁移之前.
Unable to generate an explicit migration because the following explicit migrations are pending: [20161081751088_InitialCreate, 20161091825212_ClientID]. Apply the pending explicit migrations before attempting to generate a new explicit migration.
我运行了一个更新命令:
I ran an update command:
PM> Update-Database
但是:
数据库中已经有一个名为"AspNetRoles"的对象.
There is already an object named 'AspNetRoles' in the database.
我在线研究并找到了该解决方案:
I researched online and found this solution:
PM> Add-Migration InitialMigrations -IgnoreChanges
但是后来我又遇到了第一个错误:
But then I got the first error again:
由于以下原因,无法生成显式迁移显式迁移尚在等待中:[20161081751088_InitialCreate,20161091825212_ClientID].应用待处理的显式迁移尝试生成新的显式迁移之前.
Unable to generate an explicit migration because the following explicit migrations are pending: [20161081751088_InitialCreate, 20161091825212_ClientID]. Apply the pending explicit migrations before attempting to generate a new explicit migration.
我该如何解决这个问题?
How can I solve this problem?
推荐答案
-
删除项目中的迁移"文件夹
Remove the Migrations folder in your project
从数据库中删除 _MigrationHistory
表.
这篇关于添加迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!