I am using FluentMigrator to manage my database changes, I execute my migrations like this:
const string connectionString = @"Data Source=localhost, 1433;Initial Catalog=testdb;Integrated Security=SSPI;";
Announcer announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
announcer.ShowSql = true;
Assembly assembly = Assembly.GetAssembly(typeof (MigrationMarker));
IRunnerContext migrationContext = new RunnerContext(announcer);
var options = new ProcessorOptions
{
PreviewOnly = false, // set to true to see the SQL
Timeout = 60
};
var factory = new SqlServer2008ProcessorFactory();
IMigrationProcessor processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
What I can't figure out though, is how to execute a migration for a specific profile?
So given that my migrator has an attribute like this:
[Profile("DevMigration")]
public class DevMigration : FluentMigrator.Migration
{
I have tried a few variations of:
runner.ProfileLoader.FindProfilesIn(assembly, "DevMigrator");
runner.ApplyProfiles();
But I'm not getting any closer, does anyone know how I can execute a profile migration using the runner?
Stas Ivanov :
For the people reading it much later and using in-process migrator as it's shown in the docs here. The way to specify Profile name in this case is adding another Configure call on ServiceCollection like this:\n\n .Configure<RunnerOptions>(cfg =>\n {\n cfg.Profile = \"DevMigration\";\n })\n",
2019-06-05T09:45:13