Database.Exists Method (String)

[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]

Checks whether or not the database exists on the server. 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.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

Syntax

'Declaration
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
Public Shared Function Exists ( _
    nameOrConnectionString As String _
) As Boolean
'Usage
Dim nameOrConnectionString As String 
Dim returnValue As Boolean 

returnValue = Database.Exists(nameOrConnectionString)
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
public static bool Exists(
    string nameOrConnectionString
)
[SuppressMessageAttribute(L"Microsoft.Reliability", L"CA2000:Dispose objects before losing scope")]
public:
static bool Exists(
    String^ nameOrConnectionString
)
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")>]
static member Exists : 
        nameOrConnectionString:string -> bool
public static function Exists(
    nameOrConnectionString : String
) : boolean

Parameters

  • nameOrConnectionString
    Type: System.String
    The database name or a connection string to the database.

Return Value

Type: System.Boolean
True if the database exists; false otherwise.

See Also

Reference

Database Class

Exists Overload

System.Data.Entity Namespace