How do I undo the last Add-Migration command?

I created the migration using the Add-Migration command, but I would like to change the name of this migration. How can I cancel a migration command so that I can restore it using a new name?

Is it just a matter of deleting the generated files, or could this be a bad idea?

+59
entity-framework-5 entity-framework code-first-migrations
Jan 23 '14 at 15:13
source share
3 answers

If you have not used Update-Database , you can simply delete it. If you started the update, return it using Update-Database -TargetMigration "NameOfPreviousMigration" , and then delete it.

Link:

http://elegantcode.com/2012/04/12/entity-framework-migrations-tips/

+88
Jan 23 '14 at 15:32
source share

If you have not yet completed the migration using Update-Database, you can run Add-Migration again with the same name (you may need to use -Force) to restart the forests. This is noted in the output of the Add-Migration command.

+10
Jan 23 '14 at 19:18
source share

With EntityFrameworkCore 2.0, a snapshot of the model appears. To update the model snapshot, you will need to run the delete migration command. I read that EF Core will recognize any update and will return a snapshot for you if you manually delete the migration, but that did not work for me.

https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations

https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet#dotnet-ef-migrations-remove

+1
Oct 25 '17 at 0:07
source share



All Articles