Database.Delete Database.Delete Database.Delete Method

Definition

Overloads

Delete() Delete() Delete()

Deletes the database on the database server if it exists, otherwise does nothing. Calling this method from outside of an initializer will mark the database as having not been initialized. This means that if an attempt is made to use the database again after it has been deleted, then any initializer set will run again and, usually, will try to create the database again automatically.

Delete(DbConnection) Delete(DbConnection) Delete(DbConnection)

Deletes the database on the database server if it exists, otherwise does nothing.

Delete(String) Delete(String) Delete(String)

Deletes the database on the database server if it exists, otherwise does nothing. The connection to the database is created using the given database name or connection string in the same way as is described in the documentation for the DbContext class.

Delete() Delete() Delete()

Deletes the database on the database server if it exists, otherwise does nothing. Calling this method from outside of an initializer will mark the database as having not been initialized. This means that if an attempt is made to use the database again after it has been deleted, then any initializer set will run again and, usually, will try to create the database again automatically.

public bool Delete ();
member this.Delete : unit -> bool
Public Function Delete () As Boolean

Returns

True if the database did exist and was deleted; false otherwise.

Delete(DbConnection) Delete(DbConnection) Delete(DbConnection)

Deletes the database on the database server if it exists, otherwise does nothing.

public static bool Delete (System.Data.Common.DbConnection existingConnection);
static member Delete : System.Data.Common.DbConnection -> bool
Public Shared Function Delete (existingConnection As DbConnection) As Boolean

Parameters

existingConnection
DbConnection DbConnection DbConnection

An existing connection to the database.

Returns

True if the database did exist and was deleted; false otherwise.

Delete(String) Delete(String) Delete(String)

Deletes the database on the database server if it exists, otherwise does nothing. The connection to the database is created using the given database name or connection string in the same way as is described in the documentation for the DbContext class.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
public static bool Delete (string nameOrConnectionString);
static member Delete : string -> bool
Public Shared Function Delete (nameOrConnectionString As String) As Boolean

Parameters

nameOrConnectionString
String String String

The database name or a connection string to the database.

Returns

True if the database did exist and was deleted; false otherwise.

Applies to