Created
February 13, 2013 20:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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