I'm using the DbMigrator
class to get a list of pending migrations. For some reason it returns no items even though there are pending migrations. Am i missing a step?
var configuration = new Migrations.Configuration();
configuration.TargetDatabase = new DbConnectionInfo("MyDatabase");
var migrator = new DbMigrator(configuration);
var migs = migrator.GetPendingMigrations().ToList();
Console.WriteLine(migrator.GetPendingMigrations().ToString());
I thought it might be the connection string but what's interesting is that migrator.GetDatabaseMigrations()
returns the correct list of migrations already applied to the db.
I arrived at his question when trying to solve this in Entity framework core. Posting how I fixed it in case someone else also randomly gets to this question trying to solve this.
This is the solution on how to fix this in EF Core.
I added this Extension method to my code
And I call it in Startup.cs from