private static void CheckPersistentStoreStatus(Version databaseVersion, Version assemblyVersion) { if (databaseVersion.Equals(assemblyVersion)) { Console.WriteLine("The database is up-to-date."); Environment.ExitCode = 0; return; } var ep = new PersistentStoreUpgradeScriptExtensionPoint(); var extensions = ep.CreateExtensions(); var found = false; foreach (IPersistentStoreUpgradeScript script in extensions) { if (script.SourceVersion.Equals(databaseVersion)) { found = true; break; } } if (found) { Console.WriteLine("The database must be upgraded from {0} to {1}", databaseVersion.ToString(4), assemblyVersion.ToString(4)); Environment.ExitCode = 1; } else { Console.WriteLine("An unsupported version ({0}) is installed which cannot be upgraded from", databaseVersion.ToString(4)); Environment.ExitCode = -1; } }
private static bool UpdatePersistentStore(Version startingVersion, Version assemblyVersion) { var currentVersion = startingVersion; var ep = new PersistentStoreUpgradeScriptExtensionPoint(); var extensions = ep.CreateExtensions(); while (!currentVersion.Equals(assemblyVersion)) { var found = false; foreach (IPersistentStoreUpgradeScript script in extensions) { if (script.SourceVersion.Equals(currentVersion)) { try { script.Execute(); } catch (Exception e) { Console.WriteLine("Unexpected Exception when executing upgrade script : {0}", e.Message); Console.WriteLine("Call stack : {0}", e.StackTrace); return(false); } Console.WriteLine("The database has been upgraded from version {0} to version {1}", currentVersion.ToString(4), script.DestinationVersion.ToString(4)); currentVersion = script.DestinationVersion; found = true; break; } } if (!found) { Console.WriteLine("Unable to find upgrade script for {0}", currentVersion.ToString(4)); return(false); } } return(true); }
private static void CheckPersistentStoreStatus(Version databaseVersion, Version assemblyVersion) { if (databaseVersion.Equals(assemblyVersion)) { Console.WriteLine("The database is up-to-date."); Environment.ExitCode = 0; return; } var ep = new PersistentStoreUpgradeScriptExtensionPoint(); var extensions = ep.CreateExtensions(); var found = false; foreach (IPersistentStoreUpgradeScript script in extensions) { if (script.SourceVersion.Equals(databaseVersion)) { found = true; break; } } if (found) { Console.WriteLine("The database must be upgraded from {0} to {1}", databaseVersion.ToString(4), assemblyVersion.ToString(4)); Environment.ExitCode = 1; } else { Console.WriteLine("An unsupported version ({0}) is installed which cannot be upgraded from", databaseVersion.ToString(4)); Environment.ExitCode = -1; } }
private static bool UpdatePersistentStore(Version startingVersion, Version assemblyVersion) { var currentVersion = startingVersion; var ep = new PersistentStoreUpgradeScriptExtensionPoint(); var extensions = ep.CreateExtensions(); while (!currentVersion.Equals(assemblyVersion)) { var found = false; foreach (IPersistentStoreUpgradeScript script in extensions) { if (script.SourceVersion.Equals(currentVersion)) { try { script.Execute(); } catch (Exception e) { Console.WriteLine("Unexpected Exception when executing upgrade script : {0}", e.Message); Console.WriteLine("Call stack : {0}", e.StackTrace); return false; } Console.WriteLine("The database has been upgraded from version {0} to version {1}", currentVersion.ToString(4), script.DestinationVersion.ToString(4)); currentVersion = script.DestinationVersion; found = true; break; } } if (!found) { Console.WriteLine("Unable to find upgrade script for {0}", currentVersion.ToString(4)); return false; } } return true; }