C# 利用 DbUp 通过多个SQL Script文件完成对数据库的更新
详细流程请参考(本人测试过,很好用):
http://dbup.github.io/
配置截图:
程序如下:
static int Main(string[] args) { var connectionString = args.FirstOrDefault() ?? "Server=(local)\\SqlExpress; Database=MyApp; Trusted_connection=true"; var upgrader = DeployChanges.To .SqlDatabase(connectionString) .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()) .LogToConsole() .Build(); var result = upgrader.PerformUpgrade(); if (!result.Successful) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(result.Error); Console.ResetColor(); return -1; } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Success!"); Console.ResetColor(); return 0; }
。。。。。。。。