/// <summary> /// Deletes the database on the database server if it exists, otherwise does nothing. /// </summary> /// <param name="existingConnection"> An existing connection to the database. </param> /// <returns> True if the database did exist and was deleted; false otherwise. </returns> public static bool Delete(DbConnection existingConnection) { Check.NotNull<DbConnection>(existingConnection, nameof (existingConnection)); if (!Database.Exists(existingConnection)) return false; using (ObjectContext emptyObjectContext = Database.CreateEmptyObjectContext(existingConnection)) new DatabaseOperations().Delete(emptyObjectContext); return true; }
public static bool Delete(string nameOrConnectionString) { Check.NotEmpty(nameOrConnectionString, nameof (nameOrConnectionString)); if (!Database.Exists(nameOrConnectionString)) return false; using (LazyInternalConnection internalConnection = new LazyInternalConnection(nameOrConnectionString)) { using (ObjectContext emptyObjectContext = Database.CreateEmptyObjectContext(internalConnection.Connection)) new DatabaseOperations().Delete(emptyObjectContext); } return true; }