I have created a migration using the Add-Migration
command, but I'd like to change the name of that migration. How can I undo the migration command, so that I can regenerate it using the new desired name?
Is it just a matter of deleting the generated files, or this could be a bad idea?
You can rollback your migration by using rake db:rollback with different options. The syntax will be different according to your requirements. where n is number of migrations to rollback, counting from latest migration.
Reverting a Migration But, for some reason, you want to revert the database to the previous state. In this case, use the update-database <migration name> command to revert the database to the specified previous migration snapshot. > dotnet ef database update MyFirstMigration.
If you haven't used Update-Database
you can just delete the migration file. If you've run the update you should roll it back using Update-Database -TargetMigration "NameOfPreviousMigration"
then delete the migration file.
Reference:
http://elegantcode.com/2012/04/12/entity-framework-migrations-tips/
If you haven't executed the migration yet with Update-Database
, you can run Add-Migration
again with the same name (you may need to use -Force
) to re-execute the scaffolding. This is noted in the output of the Add-Migration
command.
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