/// <summary> /// /// </summary> /// <param name="runnerAction"></param> public void Migrate(Action <IMigrationRunner> runnerAction) { var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s)); var options = new MigrationOptions { PreviewOnly = false, Timeout = 7200 }; string dbType = ""; if (_dbType.Contains("MySql")) { dbType = "MySql"; } else if (_dbType.Contains("SqlClient")) { dbType = "SqlServer"; } else if (_dbType.Contains("SQLite")) { dbType = "SQLite"; } var factory = new FluentMigrator.Runner.Processors.MigrationProcessorFactoryProvider().GetFactory(dbType); //var assembly = Assembly.GetExecutingAssembly(); var migrationContext = new RunnerContext(announcer); var processor = factory.Create(_connectionString, announcer, options); var runner = new MigrationRunner(_assembly, migrationContext, processor); runnerAction(runner); }
public void Migrate(Action<IMigrationRunner> runnerAction) { var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 }; var factory = new FluentMigrator.Runner.Processors.MigrationProcessorFactoryProvider().GetFactory(_dbType); var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s)); var migrationContext = new RunnerContext(announcer); var processor = factory.Create(_connectionString, announcer, options); var runner = new MigrationRunner(_migrationAssembly, migrationContext, processor); runnerAction(runner); }
public void Migrate(Action <IMigrationRunner> runnerAction) { var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 }; var factory = new FluentMigrator.Runner.Processors.MigrationProcessorFactoryProvider().GetFactory(_dbType); var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s)); var migrationContext = new RunnerContext(announcer); var processor = factory.Create(_connectionString, announcer, options); var runner = new MigrationRunner(_migrationAssembly, migrationContext, processor); runnerAction(runner); }
public void MigrateToLatest() { var providerMap = new[] { new { Name = "SqlServer", Provider = "System.Data.SqlClient" }, new { Name = "MySql", Provider = "MySql.Data.MySqlClient" }, new { Name = "SQLite", Provider = "System.Data.SQLite" }, new { Name = "Postgres", Provider = "Npgsql" }, new { Name = "Firebird", Provider = "FirebirdSql.Data.FirebirdClient" }, new { Name = "SqlServerCe", Provider = "System.Data.SqlServerCe.4.0" }, new { Name = "Jet", Provider = "Microsoft.Jet.OLEDB.4.0" }, new { Name = "Hana", Provider = "Sap.Data.Hana" }, new { Name = "Db2", Provider = "IBM.Data.DB2" }, }; // Unmapped names that FluentMigrator supports but the provider invariant name isn't known // DotConnectOracle, // new { Name = "Oracle", Provider = "System.Data.OracleClient" }, // OracleManaged, // SqlServer2000, // SqlServer2005, // SqlServer2008, // SqlServer2012, // SqlServer2014, //ConnectionStringSettings css = ConfigurationManager.ConnectionStrings["DbLocal"]; this.CreateDatabaseIfNeeded(); string migrationFactoryName = providerMap.Single(item => item.Provider == this.dbLocal.ConnectionFactory.ProviderName).Name; var options = new MigrationOptions(); var announcer = new FluentMigrator.Runner.Announcers.TextWriterAnnouncer(s => Console.WriteLine(s)); //var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServerProcessorFactory(); var factory = new FluentMigrator.Runner.Processors.MigrationProcessorFactoryProvider().GetFactory(migrationFactoryName); var context = new FluentMigrator.Runner.Initialization.RunnerContext(announcer) { Namespace = "MahloService.DbMigrations", NestedNamespaces = false, }; var processor = factory.Create(this.dbLocal.ConnectionFactory.ConnectionString, announcer, options); var runner = new FluentMigrator.Runner.MigrationRunner(Assembly.GetExecutingAssembly(), context, processor); runner.MigrateUp(); }