Skip to content

Instantly share code, notes, and snippets.

@mikekwright
Created February 13, 2013 20:49
Show Gist options
  • Save mikekwright/4948116 to your computer and use it in GitHub Desktop.
Save mikekwright/4948116 to your computer and use it in GitHub Desktop.
Adding the automatic database update call that uses DbUp for the ASP.NET MVC 4 Tutorial.
public class DbUpdater
{
public void RunUpdate()
{
const string connectionString = ConnectionManager.ConnectionString;
var updater = DbUp.DeployChanges.To
.SqlDatabase(connectionString)
.WithScriptsEmbeddedInAssembly(GetType().Assembly)
.LogToConsole()
.Build();
var results = updater.PerformUpgrade();
if (!results.Successful)
{
throw results.Error;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment