Reputation: 158
I would like to programmatically specify an EF7 migration in a console application. In EF6 the code looked something like this
var dbMigrator = new DbMigrator( someDbMigrationsConfiguration );
dbMigrator.Update( "NameOfMyMigration" );
With EF7 the following code will run all of the migrations
using ( var db = new someDbContext() )
{
db.Database.Migrate();
}
But I can't find any examples or documentation on how to specify a specific migration like I'm able to do with EF6. This is using EF 7.0.0-rc1-final.
Upvotes: 2
Views: 443
Reputation: 158
Okay, despite spending the better part of this afternoon searching for an answer I found one nearly immediately after posting. Here's the EF7 equivalent:
using ( var db = new someDbContext() )
{
var migrator = db.GetInfrastructure().GetRequiredService<IMigrator>();
migrator.Migrate( "NameOfMyMigration" );
}
Upvotes: 4