private IServiceProvider ConfigureOptionsAndCreateServiceProvider() { return(new ServiceCollection() // Add common FluentMigrator services .AddFluentMigratorCore() .Configure <FluentMigratorLoggerOptions>( opt => { opt.ShowElapsedTime = ShowElapsedTime; opt.ShowSql = ShowSql; }) .ConfigureRunner(rb => { rb = _dbAdapter.ConfigureRunner(rb); rb // Define the assembly containing the migrations .ScanIn(_migrationAssembly) .For.Migrations() .For.EmbeddedResources() .ConfigureGlobalProcessorOptions(opt => { opt.PreviewOnly = PreviewOnly; }) ; }) // Enable logging to console in the FluentMigrator way .AddLogging(lb => { lb.AddFluentMigratorConsole(); }) .Configure <RunnerOptions>(ro => { /* * This is where different migrations can be selected based on their tags. * ro.Tags = new[] { "UK", "Production" } */ ro.Tags = Tags.ToArray(); }) // Build the service provider .BuildServiceProvider(false)); }