[Entity Framework] Revert the database to specified migration.
阿新 • • 發佈:2019-01-25
ati sql design 之前 問題 folding bubuko 參數 dennis
本文涉及的相關問題,如果你的問題或需求有與下面所述相似之處,請閱讀本文
[Entity Framework] Revert the database to specified migration.
[Entity Framework] Re-scaffold migration file.
對於初期沒有設計好Model的情況下, 已經add的migration並且已經update到db中之後可以通過下列命令達到重新編輯之前add的migration, 並且不會為你的項目新增migration文件.
比如我的項目已經有如下migration結構:
其中對於201901170814382_AddSlotManagement的migration,由於model模型變了我希望重新生成關於這個功能的migration.
首先將migration revert回到上一個migration
PM> Update-Database -TargetMigration 201901160836219_AddRelevanceModels Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Reverting migrations: [201901170814382_AddSlotManagement]. Reverting explicit migration: 201901170814382_AddSlotManagement.
然後重新執行add migration.記住名字一致和加上-Force參數
PM> Add-Migration 201901170814382_AddSlotManagement Re-scaffolding migration '201901170814382_AddSlotManagement'. Only the Designer Code for migration '201901170814382_AddSlotManagement' was re-scaffolded. To re-scaffold the entire migration, use the -Force parameter. PM> Add-Migration 201901170814382_AddSlotManagement -Force Re-scaffolding migration '201901170814382_AddSlotManagement'.
希望以上內容能夠幫助到遇到同樣問題的你.如有其它思路可以隨時聯系我.
[Entity Framework] Revert the database to specified migration.