I think that ef migrations must be tested. As for me integration testing will be best solution. Current solution is to apply migrations to in memory database, but problem is that i want to run down scripts of migration also.
Do yoy know how to apply migrations using c# code?
In the Startup.cs Configure method, we run migrations like this (in .Net core 2.0):
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
serviceScope.ServiceProvider.GetService<DataContext>().Database.Migrate();
}
I am not sure how you can test this. Possibly backup and restore the live database to a test one, then setup your DataContext to point to the test and run the migration there?