共用方式為


ObjectContext.DatabaseExists 方法

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

檢查在目前存放區連接中指定為資料庫的資料庫是否存在存放區上。 大部分的實際工作是由目前存放區連接的 DbProviderServices 實作所完成。

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

語法

'宣告
<SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")> _
Public Overridable Function DatabaseExists As Boolean
'用途
Dim instance As ObjectContext 
Dim returnValue As Boolean 

returnValue = instance.DatabaseExists()
[SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public virtual bool DatabaseExists()
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1031:DoNotCatchGeneralExceptionTypes")]
public:
virtual bool DatabaseExists()
[<SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")>]
abstract DatabaseExists : unit -> bool 
[<SuppressMessageAttribute("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")>]
override DatabaseExists : unit -> bool
public function DatabaseExists() : boolean

傳回值

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

請參閱

參考

ObjectContext 類別

System.Data.Entity.Core.Objects 命名空間