Your target migration should be the migration immediately previous to the one that you want to rollback:
update-database -SourceMigration MyLastMigration -TargetMigration MigrationPreviousToMyLastMigration
The SourceMigration
parameter is optional in your case, as you have not applied any migration after MyLastMigration
.
To check the name of the previous migration you can use Get-Migrations
, that returns the list of migrations applied to your database.
Edit: as Ivan Stoev says in the comments, the SourceMigration
parameter can only be included together with the parameter Script
, so it does not make sense in this scenario. The right command would be like this:
update-database -TargetMigration MigrationPreviousToMyLastMigration