Created
May 29, 2013 11:12
-
-
Save FredrikGoransson/5669536 to your computer and use it in GitHub Desktop.
Execute Migrations for FluentMigrator inside code (a unit test for instance)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Runs all migrations in the assembly of specified type | |
| private static void RunMigrations<T>(string connectionString) | |
| { | |
| var announcer = new NullAnnouncer(); | |
| //var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s)); | |
| var assembly = typeof(T).Assembly; | |
| var migrationContext = new RunnerContext(announcer); | |
| var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 }; | |
| var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServerCeProcessorFactory(); | |
| var processor = factory.Create(connectionString, announcer, options); | |
| var runner = new MigrationRunner(assembly, migrationContext, processor); | |
| runner.MigrateUp(useAutomaticTransactionManagement: true); | |
| processor.Dispose(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment