幾個星期前,我啓用了我的項目遷移,並在AspNetUsers表中添加了一個'ClientID'列。添加遷移錯誤
現在我試圖添加另一列:「名稱」。
我跑在Package Manager控制檯命令:
PM> Add-Migration "Name"
而且我得到了以下錯誤:
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.
我跑了一個更新的命令:
PM> Update-Database
但是:
There is already an object named 'AspNetRoles' in the database.
我在網上進行搜索,發現這個解決方案:
PM> Add-Migration InitialMigrations -IgnoreChanges
但後來我又拿到了第一個錯誤:
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.
我怎樣才能解決這個問題?
如果您已經更新了數據庫,請嘗試使用'Update-Database -TargetMigration [PreviousMigrationName]'回滾以前的遷移版本,然後將其刪除。其他考慮的方法是從EF項目的'Migrations'文件夾中排除/刪除'[20161081751088_InitialCreate]'和'[20161091825212_ClientID]''。 –