EF Migrations: Rollback last applied migration?

后端 未结 15 1175
终归单人心
终归单人心 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

    In case there is a possibility for dataloss EF does not complete the update-database command since AutomaticMigrationDataLossAllowed = false by default, and roolbacks the action unless you run it with the -force parameter.

    Update-Database –TargetMigration:"Your migration name" -force
    

    or

    Update-Database –TargetMigration:Your_Migration_Index -force
    

提交回复
热议问题