Beispiel #1
0
        public void MigrateToLatest()
        {
            try
            {
                var connectionString = _settingsService.ConnectionString(DatabaseContext.DefaultConnectionString);

                var announcer = new NullAnnouncer();

                var assembly = Assembly.GetExecutingAssembly();

                var migrationContext = new RunnerContext(announcer)
                {
                    NestedNamespaces = true,
                    Namespace        = "Database.Migrations",
                    Connection       = connectionString
                };
                var options = new MigrationOptions {
                    PreviewOnly = false, Timeout = 60
                };
                var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2014ProcessorFactory();
                using (var processor = factory.Create(connectionString, announcer, options))
                {
                    var runner = new MigrationRunner(assembly, migrationContext, processor);
                    runner.MigrateUp(true);
                }
            }
            catch (Exception e)
            {
            }
        }