EF7 Migration Rollback?
using EntityFramework 7.0.0.-beta1
Is it possible to roll back migrations yet? If so, I am assuming that it is a "k ef migration" command?
Looks like the PM command is remove-migration https://github.com/aspnet/EntityFramework/blob/dev/src/EntityFramework.Commands/tools/EntityFramework.psd1
Remove-Migration (or k ef migration remove) is only about removing unapplied migrations from your project.
To rollback (or unapply) migrations from the database, use Apply-Migration TargetMigration (or k ef migration apply targetMigration) where TargetMigration is the name of the migration you want to rollback to.
To rollback all migrations, use Apply-Migration 0.
k ef migration apply 0 works !! Thank you so much!
that 0 should be documented!!
@Bartmax I'll make sure it gets done as part of #578
Excellent! thanks.
Hi. I'm not sure if this is the right place to post question. Excuse-me if I'm wrong.
I am trying to unapply a migration and I'm getting the following message:
The migration '20161108115840_CriaTabelaUnidade' has already been applied to the database. Unapply it and try again. If the migration has been applied to other databases, consider reverting its changes using a new migration.
Next, I'm trying to unapply this migration. But the command Apply-Migration isn't recognized.
And I didn't find any reference to this command in the docs: https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell
Is there another way to unapply migrations?
@adrianorc To revert (or unapply) a migration from the database use Update-Database ThePreviousMigration. To remove (or delete) a migration from the project, use Remove-Migration.
@bricelam Worked. Thank you!