|
Project Information
Featured
Downloads
Links
|
DbUp is an opinionated library for deploying and upgrading SQL server database schemas the right way. Getting startedDbUp ships as a .NET assembly that you reference from WPF, Windows Forms, ASP.NET or Console applications. You can use it to programmatically deploy your database. Start with a fresh Visual Studio Console Application project, and reference DbUp.dll. Add some SQL scripts, using numbers to put them in the right order:
Add the following code to Program.cs execute your scripts: //Basic configuration:-
//This configuration assumes:
// * you are using SQL Server
// * want to log to the Console
var upgrader = new DatabaseUpgrader(
Settings.Default.MyDbConnectionString,
new EmbeddedScriptProvider(typeof(Program).Assembly)
);
var result = upgrader.PerformUpgrade();
if (result.Successful)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success!");
Console.ReadKey();
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(result.Error);
Console.ReadKey();
Console.WriteLine("Failed!");
}See the included sample application for more details. HistoryDatabase deployments based on change scripts is a very old concept; I've used various incarnations of this approach for the past five years. The code in this project was forked from the FunnelWeb blog engine. |