如何使用 FluentMigrator 运行配置文件迁移?

she*_*nku 4 c# fluent-migrator

我正在使用 FluentMigrator 来管理我的数据库更改,我像这样执行迁移:

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);
Run Code Online (Sandbox Code Playgroud)

但我不明白的是如何针对特定配置文件执行迁移?

鉴于我的迁移器具有如下属性:

[Profile("DevMigration")]
public class DevMigration : FluentMigrator.Migration
{
Run Code Online (Sandbox Code Playgroud)

我尝试过以下几种变体:

runner.ProfileLoader.FindProfilesIn(assembly, "DevMigrator");
runner.ApplyProfiles();
Run Code Online (Sandbox Code Playgroud)

但我还没有更进一步,有谁知道如何使用运行程序执行配置文件迁移?

Sta*_*nov 5

对于后来阅读它并使用进程内迁移器的人来说,如此处文档中所示。在这种情况下指定配置文件名称的方法是在 ServiceCollection 上添加另一个配置调用,如下所示:

            .Configure<RunnerOptions>(cfg =>
            {
                cfg.Profile = "DevMigration";
            })
Run Code Online (Sandbox Code Playgroud)