ObjectContext.DatabaseExists 方法

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 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 命名空间