Hi,
I would like to inform the user if there are open migrations before they are applied.
Is there currently a way to do this in wpf and windows Forms projects?
Sometimes the migrations can take very long and therefor I would like to show the user a progressbar with the status of the migration, otherwise he could kill the process and destroy the database, because he doesn't know that the migration is still running.
Is there already an option available to do this?
regards
Benny
Here is the code to find the pending migrations and then apply them one at a time so that you can write status etc.
``` c#
using (var context = new TestContext())
{
var all = context.GetService
var applied = context.GetService
var pending = all.Except(applied).ToArray();
var migrator = context.GetService<IMigrator>();
for (int i = 0; i < pending.Length; i++)
{
Console.WriteLine($"Applying {pending[i]} {i + 1}/{pending.Length}");
migrator.Migrate(targetMigration: pending[i]);
}
}
```
Also opened #6110 to add the ability to get all/applied/pending migrations with a top level API (as having to write all that code in the above example is pretty ugly for a relatively simple task).