I made a in my model and updated database using
Add-Migration sdfgfsd
Update-Database
Now I found the change I just made is not necessary.
I would like do revert both code and database.
How can I do this?
How do I rollback Entity Framework Code First migration? You can also Undo/Rollback specific migrations by using the following commands: Rollback to a specific migrations. Update-Database -TargetMigration:MigrationsName.
Reverting a Migration In this case, use the update-database <migration name> command to revert the database to the specified previous migration snapshot.
Yes - it's straightforward. Use
Update-Database -TargetMigration:zzzz
Where zzzz
is the name of the migration before the one you want to rollback.
EDIT You then need to delete the migration(s) after zzzz.
If you want to rollback all migrations, or if you only have one migration, use
update-database -target:0
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