EF Migrations: Rollback last applied migration?

后端 未结 15 1214
终归单人心
终归单人心 2020-12-02 03:39

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, lik

15条回答
  •  甜味超标
    2020-12-02 03:52

    As of EF 5.0, the approach you describe is the preferred way. So

    PM> Update-Database -TargetMigration:"NameOfSecondToLastMigration"

    or using your example migrations

    PM> Update-Database -TargetMigration:"CategoryIdIsLong"

    One solution would be to create a wrapper PS script that automates the steps above. Additionally, feel free to create a feature request for this, or better yet, take a shot at implementing it! https://github.com/dotnet/ef6

提交回复
热议问题