Created
July 13, 2015 06:40
-
-
Save davidhagg/d6e45e002325e3e1c3cd to your computer and use it in GitHub Desktop.
This file contains 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
private void ExecuteMigrationScripts(IEnumerable<KeyValuePair<IMigrationScriptFile, string>> scripts, Action<DbTransaction, long> updateVersionAction) | |
{ | |
using (DbTransaction tran = Database.BeginTransaction()) | |
{ | |
IMigrationScriptFile currentScript = null; | |
try | |
{ | |
foreach (var script in scripts) | |
{ | |
currentScript = script.Key; | |
Database.ExecuteScript(tran, script.Value); | |
updateVersionAction(tran, script.Key.Version); | |
} | |
tran.Commit(); | |
} | |
catch (Exception ex) | |
{ | |
tran.Rollback(); | |
string filePath = (currentScript == null) ? "NULL" : currentScript.FilePath; | |
throw new MigrationException("Error executing migration script: " + filePath, filePath, ex); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment