本文整理汇总了C#中FluentMigrator.Runner.Initialization.RunnerContext类的典型用法代码示例。如果您正苦于以下问题:C# RunnerContext类的具体用法?C# RunnerContext怎么用?C# RunnerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RunnerContext类属于FluentMigrator.Runner.Initialization命名空间,在下文中一共展示了RunnerContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: StartMigration
public void StartMigration()
{
var consoleAnnouncer = new TextWriterAnnouncer(System.Console.Out)
{
ShowElapsedTime = true,
ShowSql = true
};
var runnerContext = new RunnerContext(consoleAnnouncer)
{
Database= DataBaseType,
Connection=connStr,
Target=assemblyPath,
PreviewOnly= false,
Namespace=string.Empty,
Task=string.Empty,
Version=0,
Steps=1,
WorkingDirectory = currentPath,
Profile=string.Empty,
Timeout=0,
ConnectionStringConfigPath=string.Empty
};
TaskExecutor tskMigration = new TaskExecutor(runnerContext);
tskMigration.Execute();
}
开发者ID:majimenezp,项目名称:AppGen,代码行数:26,代码来源:MigratorExecuter.cs
示例2: RunMigrations
public static void RunMigrations(string connectionString, string migration)
{
// var announcer = new NullAnnouncer();
var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer)
{
Namespace = "Azimuth.Migrations",
WorkingDirectory = "Migrations"
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
switch (migration)
{
case "Run migrations":
runner.MigrateUp(true);
break;
case "Drop all tables":
runner.RollbackToVersion(201408091845);
runner.Rollback(1);
break;
}
}
开发者ID:IhorSyerkov,项目名称:Azimuth,代码行数:28,代码来源:Runner.cs
示例3: UpgradeDatabase
public void UpgradeDatabase()
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var announcer = new TextWriterAnnouncer(s => Log.Debug(s));
var context = new RunnerContext(announcer)
{
Namespace = "Causal.Server.Migrations"
};
var providerName = ConfigurationManager.ConnectionStrings["CausalContext"].ProviderName;
MigrationProcessorFactory factory;
if (providerName.Equals("Npgsql", StringComparison.InvariantCultureIgnoreCase))
{
factory = new FluentMigrator.Runner.Processors.Postgres.PostgresProcessorFactory();
}
else if (providerName.Equals("System.Data.SqlClient", StringComparison.InvariantCultureIgnoreCase))
{
factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
}
else
{
throw new Exception("Unknown provider for connection string CausalContext");
}
var options = new ProcessorOptions { PreviewOnly = false };
var processor = factory.Create(ConfigurationManager.ConnectionStrings["CausalContext"].ConnectionString, announcer, options);
var migrator = new MigrationRunner(assembly, context, processor);
migrator.MigrateUp(true);
}
开发者ID:jennings,项目名称:Causal,代码行数:30,代码来源:Startup.cs
示例4: Main
public void Main(string[] args)
{
BuildConfiguration(args);
PrintLogo();
var csName = Configuration["cs"];
var runnerContext = new RunnerContext(new ConsoleAnnouncer())
{
Database = "SqlServer",
Connection = Configuration[$"Data:{csName}:ConnectionString"],
Targets = new string[] { Configuration["target"] },
PreviewOnly = false,
NestedNamespaces = true,
Task = "migrate",
StartVersion = 0,
NoConnection = false,
Steps = 1,
WorkingDirectory = ".",
TransactionPerSession = true
};
new TaskExecutor(runnerContext).Execute();
Console.ReadLine();
}
开发者ID:pgrudzien12,项目名称:fluentmigrator.commands,代码行数:25,代码来源:Program.cs
示例5: Migrate
public void Migrate(string connectionString, MigrationContext migrationContext)
{
var sw = Stopwatch.StartNew();
_announcer.Heading("Migrating " + connectionString);
var assembly = Assembly.GetExecutingAssembly();
var runnerContext = new RunnerContext(_announcer)
{
Namespace = "NzbDrone.Core.Datastore.Migration",
ApplicationContext = migrationContext
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new NzbDroneSqliteProcessorFactory();
var processor = factory.Create(connectionString, _announcer, options);
var runner = new MigrationRunner(assembly, runnerContext, processor);
if (migrationContext.DesiredVersion.HasValue)
{
runner.MigrateUp(migrationContext.DesiredVersion.Value, true);
}
else
{
runner.MigrateUp(true);
}
sw.Stop();
_announcer.ElapsedTime(sw.Elapsed);
}
开发者ID:mike-tesch,项目名称:Sonarr,代码行数:32,代码来源:MigrationController.cs
示例6: MigrateToLatest
public void MigrateToLatest(string connectionString, MigrationType migrationType)
{
lock (MigrationCache)
{
if (MigrationCache.Contains(connectionString.ToLower())) return;
_announcer.Heading("Migrating " + connectionString);
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(_announcer)
{
Namespace = "NzbDrone.Core.Datastore.Migration",
ApplicationContext = new MigrationContext
{
MigrationType = migrationType,
SQLiteAlter = _sqLiteAlter,
MigrationHelper = _migrationHelper,
}
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new SqliteProcessorFactory();
var processor = factory.Create(connectionString, _announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
MigrationCache.Add(connectionString.ToLower());
}
}
开发者ID:peterlandry,项目名称:NzbDrone,代码行数:30,代码来源:MigrationController.cs
示例7: Run
public static void Run(IContainer settingsContainer)
{
var connectionString = settingsContainer.GetInstance<string>("DefaultConnection");
Announcer announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
announcer.ShowSql = true;
Assembly assembly = typeof(CreateTableEstacionamento).Assembly;
IRunnerContext migrationContext = new RunnerContext(announcer);
var options = new ProcessorOptions
{
PreviewOnly = false, // set to true to see the SQL
Timeout = 60
};
try
{
var factory = settingsContainer.GetInstance<MigrationProcessorFactory>(); //new FluentMigrator.Runner.Processors.SQLite.SQLiteProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
}
catch (Exception ex)
{
throw new InvalidOperationException("connectionString: " + connectionString, ex);
}
}
开发者ID:marcosli,项目名称:multi-vagas,代码行数:30,代码来源:MigrationsRunner.cs
示例8: Migrate
/// <summary>
/// Migrates the specified file name and path.
/// <remarks>This method is called directly when performing integration tests.</remarks>
/// </summary>
/// <param name="fileNameAndPath">The file name and path.</param>
/// <param name="withBackup">if set to <c>true</c> [with backup].</param>
/// <param name="withAnnouncer">if set to <c>true</c> [with announcer].</param>
public static void Migrate(string fileNameAndPath, bool withBackup = false, bool withAnnouncer = false)
{
var currentDb = new FileInfo(fileNameAndPath);
var backupDb = string.Empty;
if (withBackup) { Backup(currentDb); }
var emptyAnnouncers = new Announcer[] { };
var consoleAnnouncer = new Announcer[] { new ConsoleAnnouncer() };
var announcerToProvide = new CompositeAnnouncer(withAnnouncer ? consoleAnnouncer : emptyAnnouncers);
var ctx = new RunnerContext(announcerToProvide)
{
ApplicationContext = string.Empty,
Database = "sqlite",
Connection = string.Format(CONNECTION_STRING_FORMAT, fileNameAndPath).NormalizePathSeparator(),
Targets = new[] { "Drey.Configuration" }
};
try
{
var executor = new TaskExecutor(ctx);
executor.Execute();
}
catch (Exception)
{
if (withBackup)
{
currentDb.Delete();
if (!string.IsNullOrWhiteSpace(backupDb)) { File.Copy(backupDb, currentDb.FullName); }
}
throw;
}
}
开发者ID:dealproc,项目名称:Drey,代码行数:42,代码来源:MigrationManager.cs
示例9: ApplicationStartup
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
var announcer = new NullAnnouncer();
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer)
{
Namespace = "Server.Migrations"
};
var options = new MigrationOptions();
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
var processor = factory.Create(
ConfigurationManager.ConnectionStrings["Simple.Data.Properties.Settings.DefaultConnectionString"].ConnectionString,
announcer,
options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new UserValidator(), "CPNRealm"));
JsonSettings.RetainCasing = true;
StaticConfiguration.DisableErrorTraces = false;
}
开发者ID:ChristopherMeek,项目名称:CornishPlaceNames,代码行数:27,代码来源:MigratingBootstrapper.cs
示例10: Run
public static void Run(string connectionString)
{
var firstMigration = typeof(Lucid.Database.Migrations.Y2016.M01.V01);
var assembly = new SingleAssembly(firstMigration.Assembly);
var migrationGenerator = new SqlServer2008Generator();
var announcer = new NullAnnouncer();
var options = new ProcessorOptions();
var dbFactory = new SqlServerDbFactory();
var runnerContext = new RunnerContext(announcer)
{
Database = "SqlServer2008",
Connection = connectionString,
Targets = new string[] { firstMigration.Assembly.FullName },
NestedNamespaces = true,
Namespace = "Lucid.Database.Migrations",
};
using (var connection = new SqlConnection(connectionString))
using (var processor = new SqlServerProcessor(connection, migrationGenerator, announcer, options, dbFactory))
{
var runner = new MigrationRunner(assembly, runnerContext, processor);
runner.MigrateUp();
}
}
开发者ID:FlukeFan,项目名称:LucidDotNet,代码行数:27,代码来源:LucidMigrationRunner.cs
示例11: GetMigrationContext
private RunnerContext GetMigrationContext(long version, string profile)
{
var context = new RunnerContext(Announcer);
if (version > -1)
context.Version = version;
if (!string.IsNullOrEmpty(profile))
context.Profile = profile;
return context;
}
开发者ID:rivardja,项目名称:ph-onion-demo,代码行数:9,代码来源:Runner.cs
示例12: GetRunner
private static MigrationRunner GetRunner(string connectionString, IMigrationProcessorFactory factory)
{
var announcer = new NullAnnouncer();
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer) { Namespace = "Migrations" };
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var processor = factory.Create(connectionString, announcer, options);
return new MigrationRunner(assembly, migrationContext, processor);
}
开发者ID:thesheps,项目名称:schema-normaliser,代码行数:10,代码来源:Runner.cs
示例13: Migrate
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);
}
开发者ID:lfreneda,项目名称:EasyLocalDb,代码行数:10,代码来源:Migrator.cs
示例14: MigrateTo
private void MigrateTo(long targetVersion)
{
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var announcer = new NullAnnouncer();
var processor = new SqlServer2012ProcessorFactory().Create(connectionString, announcer, options);
var migrationContext = new RunnerContext(announcer) { Namespace = "DDDEastAnglia.DatabaseMigrations.Migrations" };
var runner = new MigrationRunner(GetType().Assembly, migrationContext, processor);
runner.MigrateUp(targetVersion, true);
}
开发者ID:philpursglove,项目名称:DDDEastAnglia,代码行数:10,代码来源:Migrator.cs
示例15: Run
/// <summary>
/// Runs the migration
/// </summary>
public virtual void Run()
{
using (var connection = new SqlConnection(_connectionString))
{
var context = new RunnerContext(Announcer);
var processor = GenerateProcessor(connection);
var runner = GenerateRunner(context, processor);
runner.MigrateUp();
}
}
开发者ID:nucleoid,项目名称:Template-Project,代码行数:13,代码来源:Runner.cs
示例16: Run
public static void Run()
{
ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["BeerConf"];
var runnerContext = new RunnerContext(new NullAnnouncer())
{
Database = "sqlserver",
Connection = connectionString.ConnectionString,
Target = typeof(MigrationsRunner).Assembly.FullName,
};
new TaskExecutor(runnerContext).Execute();
}
开发者ID:hazzik,项目名称:beerconf-website,代码行数:11,代码来源:MigrationsRunner.cs
示例17: Migrate
public void Migrate(Action<IMigrationRunner> runnerAction)
{
var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
var assembly = Assembly.GetExecutingAssembly();
var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
var migrationContext = new RunnerContext(announcer);
var processor = factory.Create(this._connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runnerAction(runner);
}
开发者ID:andreialex007,项目名称:EStore,代码行数:11,代码来源:Migrator.cs
示例18: Update
public static void Update(IAnnouncer announcer, MigrationProcessorType type, string connectionString, Assembly migrationAssembly)
{
var context = new RunnerContext(announcer);
var options = new ProcessorOptions();
var factory = GetProcessorFactory(type);
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(migrationAssembly, context, processor);
runner.MigrateUp();
}
开发者ID:jasonlaflair,项目名称:LaFlair.Core,代码行数:12,代码来源:MigrationEngine.cs
示例19: Migrate
public void Migrate()
{
var processor = GetProcessor();
var context = new RunnerContext(new NullAnnouncer());
var migrationRunner = new MigrationRunner(
typeof (SqlSchemaMigrator).Assembly,
context,
processor);
migrationRunner.MigrateUp();
}
开发者ID:hadouken,项目名称:peach,代码行数:12,代码来源:SqlSchemaMigrator.cs
示例20: MigrateToLatestVersion
public static void MigrateToLatestVersion(string connectionString)
{
var migrationContext = new RunnerContext(new Log4NetAnnouncer())
{
Connection = connectionString,
Database = DefaultProvider,
Target = typeof(Migrate).Assembly.GetName().Name
};
var executor = new TaskExecutor(migrationContext);
executor.Execute();
}
开发者ID:bekk,项目名称:dotnetkurs,代码行数:12,代码来源:Migrate.cs
注:本文中的FluentMigrator.Runner.Initialization.RunnerContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论