internal override void EnsureDatabaseExists(Action mustSucceedToKeepDatabase) { var databaseCreated = false; var databaseCreator = new DatabaseCreator(_configuration.CommandTimeout); using (var connection = CreateConnection()) { if (_existenceState == DatabaseExistenceState.DoesNotExist || (_existenceState == DatabaseExistenceState.Unknown && !databaseCreator.Exists(connection))) { databaseCreator.Create(connection); databaseCreated = true; } } _emptyMigrationNeeded = databaseCreated; try { mustSucceedToKeepDatabase(); } catch { if (databaseCreated && !_historyRepository.HasMigrations()) { try { using (var connection = CreateConnection()) { databaseCreator.Delete(connection); } } catch { // Intentionally swallowing this exception since it is better to throw the // original exception again for the user to see what the real problem is. An // exception here is unlikely and would not be a root cause, but rather a // cleanup issue. } } throw; } }
internal override void EnsureDatabaseExists(Action mustSucceedToKeepDatabase) { var databaseCreated = false; var databaseCreator = new DatabaseCreator(_configuration.CommandTimeout); { DbConnection connection = null; try { connection = CreateConnection(); if (_existenceState == DatabaseExistenceState.DoesNotExist || (_existenceState == DatabaseExistenceState.Unknown && !databaseCreator.Exists(connection))) { databaseCreator.Create(connection); databaseCreated = true; } } finally { if (connection != null) { DbInterception.Dispatch.Connection.Dispose(connection, new DbInterceptionContext()); } } } _emptyMigrationNeeded = databaseCreated; try { _committedStatements = false; mustSucceedToKeepDatabase(); } catch { if (databaseCreated && !_committedStatements) { DbConnection connection = null; try { connection = CreateConnection(); databaseCreator.Delete(connection); } catch { // Intentionally swallowing this exception since it is better to throw the // original exception again for the user to see what the real problem is. An // exception here is unlikely and would not be a root cause, but rather a // cleanup issue. } finally { if (connection != null) { DbInterception.Dispatch.Connection.Dispose(connection, new DbInterceptionContext()); } } } throw; } }
internal override void EnsureDatabaseExists(Action mustSucceedToKeepDatabase) { bool flag = false; System.Data.Entity.Migrations.Utilities.DatabaseCreator databaseCreator = new System.Data.Entity.Migrations.Utilities.DatabaseCreator(this._configuration.CommandTimeout); DbConnection connection1 = (DbConnection)null; try { connection1 = this.CreateConnection(); if (this._existenceState != DatabaseExistenceState.DoesNotExist) { if (this._existenceState == DatabaseExistenceState.Unknown) { if (databaseCreator.Exists(connection1)) { goto label_8; } } else { goto label_8; } } databaseCreator.Create(connection1); flag = true; } finally { if (connection1 != null) { DbInterception.Dispatch.Connection.Dispose(connection1, new DbInterceptionContext()); } } label_8: this._emptyMigrationNeeded = flag; try { this._committedStatements = false; mustSucceedToKeepDatabase(); } catch { if (flag && !this._committedStatements) { DbConnection connection2 = (DbConnection)null; try { connection2 = this.CreateConnection(); databaseCreator.Delete(connection2); } catch { } finally { if (connection2 != null) { DbInterception.Dispatch.Connection.Dispose(connection2, new DbInterceptionContext()); } } } throw; } }
internal override void EnsureDatabaseExists(Action mustSucceedToKeepDatabase) { var databaseCreated = false; var databaseCreator = new DatabaseCreator(_configuration.CommandTimeout); using (var connection = CreateConnection()) { if (!databaseCreator.Exists(connection)) { databaseCreator.Create(connection); databaseCreated = true; } } _emptyMigrationNeeded = databaseCreated; try { mustSucceedToKeepDatabase(); } catch { if (databaseCreated) { try { using (var connection = CreateConnection()) { databaseCreator.Delete(connection); } } catch { // Intentionally swallowing this exception since it is better to throw the // original exception again for the user to see what the real problem is. An // exception here is unlikely and would not be a root cause, but rather a // cleanup issue. } } throw; } }