Share via


Database.Exists 方法 (String)

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

檢查資料庫是否存在伺服器上。 與資料庫的連接是使用給定的資料庫名稱或連接字串所建立,如同 DbContext 類別的文件中所述。

命名空間:  System.Data.Entity
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
Public Shared Function Exists ( _
    nameOrConnectionString As String _
) As Boolean
'用途
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

參數

  • nameOrConnectionString
    類型:System.String
    與資料庫連接的資料庫名稱或連接字串。

傳回值

類型:System.Boolean
如果資料庫存在則為 true,否則為 false。

請參閱

參考

Database 類別

Exists 多載

System.Data.Entity 命名空間