Database.Delete Method
Deletes the database on the database server if it exists, otherwise does nothing.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() | 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) | Deletes the database on the database server if it exists, otherwise does nothing. |
![]() ![]() | 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. |
Database.Delete Method ()
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.
Database.Delete Method (DbConnection)
Deletes the database on the database server if it exists, otherwise does nothing.
Parameters
- existingConnection
-
Type:
System.Data.Common.DbConnection
An existing connection to the database.
Database.Delete Method (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.
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] public static bool Delete( string nameOrConnectionString )
Parameters
- nameOrConnectionString
-
Type:
System.String
The database name or a connection string to the database.