本文翻译自:EF Migrations: Rollback last applied migration?
This looks like a really common task, but I can't find an easy way to do it. 这看起来是一个非常普通的任务,但是我找不到一种简单的方法。
I want to undo the last applied migration. 我想撤消上一次应用的迁移。 I would have expected a simple command, like 我本来希望有一个简单的命令,例如
PM> Update-Database -TargetMigration:"-1"
Instead, all I can come up with is: 相反,我能想到的是:
PM> Get-Migrations
Retrieving migrations that have been applied to the target database.
201208012131302_Add-SystemCategory
201207311827468_CategoryIdIsLong
201207232247409_AutomaticMigration
201207211340509_AutomaticMigration
201207200025294_InitialCreate
PM> Update-Database -TargetMigration:"CategoryIdIsLong"