C# Question

How to rollback EF 7 migrations programmatically?

I would like to write a unit test which migrates to the latest schema then tears back down to nothing.

For the migration I can do :


but how to I rollback?

Answer Source

The Commands use something like this;

var migrator = db.GetInfrastructure().GetRequiredService<IMigrator>();

Where Migration1 is the name of the migration. This suggests you can stick "0" in there to roll them all back.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download