After publishing a .Net Core RC1 application, commands specified in the project.json had corresponding .cmd files created for them which could be executed after deployment (e.g.
Within my context I have this hack from here
// Hack added so EntityFrameworkCore\Add-Migration initial works
public class ApplicationContextDbFactory : IDesignTimeDbContextFactory
{
MyContext IDesignTimeDbContextFactory.CreateDbContext(string[] args)
{
IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer(configuration.GetConnectionString("StreamCheckpointContextDB"));
return new MyContext(optionsBuilder.Options);
}
}
I made my Program.Main read like this...
public static void Main(string[] args)
{
if (args.Contains("JustMigrateMe"))
{
IDesignTimeDbContextFactory factory = new ApplicationContextDbFactory();
var ctx = factory.CreateDbContext(new string[0]);
ctx.Database.Migrate();
ctx.Dispose();
return;
}
// Other stuff
}
}
So to apply migrations I simply call the exe with the added argument.