Dorin
Dorin

Reputation: 545

DbContext.Database.Mirgate() .. what about rollback?

So there is a extension function Migrate()

dbContext.Database.Migrate();

which will apply all pending migrations to the database.

but if one of them fail . how do I roll back last step or last two migrations ?

say I have to apply A,B,C but roll back only B and C is this even possible with code?

Upvotes: 0

Views: 121

Answers (1)

Slava Utesinov
Slava Utesinov

Reputation: 13498

If you want to rollback B and C, simly specify target migration, i.e. A:

var migrator = new DbMigrator(new Configuration());
migrator.Update("A");

It is like: Update-Database -TargetMigration A

Upvotes: 2

Related Questions