Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DbMigrator.GetPendingMigrations() always empty

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.

like image 744
newbie_86 Avatar asked Sep 10 '12 13:09

newbie_86


1 Answers

The same happened to me and the reason was that I was working in a different assembly. In that case, you need to specify the assembly and namespace that contains your migrations:

config.MigrationsAssembly = Assembly.GetAssembly(typeof([One of your migration classes]));
config.MigrationsNamespace = "[Namespace containing your migrations]";
like image 198
vesan Avatar answered Sep 19 '22 11:09

vesan