.NET migrations: Setup and migrate multiple databases at runtime

梦想与她 提交于 2019-11-30 13:02:31

Since this is an old question, I assume that you have solved the problem in some manner or another, but I'll post a solution anyway for the benefit of other people stumbling across this question. It is possible to invoke MigratorDotNet from code, rather than having it as an MSBuild target:

public static void MigrateToLastVersion(string provider, string connectionString)
{
    var silentLogger = new Logger(false, new ILogWriter[0]);
    var migrator = new Migrator.Migrator(provider, connectionString, 
                   typeof(YourMigrationAssembly).Assembly, false, silentLogger);
    migrator.MigrateToLastVersion();
}

RedGate has a SQL Comparison SDK that could be used. Here is a Case Study that looks promising, but I can't tell you anthing from experience as I haven't used it. Download the trial and kick the tires.

You could use Mig# to maintain your migrations in your C# or .NET code: https://github.com/dradovic/MigSharp

Check out Fluent-Migrator.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!