Is it possible to revert database migrations on N steps back, like,
"revert 2 migrations back"
I found in the docs that we can pass parameter '0' which will revert a database to clean state.
dotnet ef database update 0
I am looking for something similar to: dotnet ef database update -2
I know, that I can do this using migration's name. But I find that sometimes much easier just enter a number, than copy/paste migration name
In package manager console, you can run the following command to rollback the migrations in your database:
Update-Database NameOfPreviousMigration
Then to the remove the migrations you can run the command Remove-Migration
in PMC to remove the penultimate migration. Run this as many times to remove the migrations, e.g. run twice to remove the last 2 migrations. This command will also updated your ModelSnapshot
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With