EntityConnection.Open 方法

定义

通过调用基础数据提供程序的 Open 方法,建立与数据源的连接。Establishes a connection to the data source by calling the underlying data provider's Open method.

public:
 override void Open();
public override void Open ();
override this.Open : unit -> unit
Public Overrides Sub Open ()

例外

打开连接时出错,或基础数据提供程序的名称未知。An error occurs when you open the connection, or the name of the underlying data provider is not known.

内联连接字符串包含一个无效的 Metadata 关键字值。The inline connection string contains an invalid Metadata keyword value.

注解

为了避免无意使对象(如 System.Data.Common.CommandTreesObjectContext)与其元数据失去同步,EntityConnection 必须锁定对象的元数据。To avoid inadvertently putting objects such as System.Data.Common.CommandTrees and ObjectContext out of sync with their metadata, EntityConnection must lock its metadata. 锁定元数据后,不允许对连接字符串做出任何更改。No changes to the connection string are allowed after the metadata is locked. 下面是锁定元数据的两种方案:The following are two scenarios in which metadata is locked:

加载元数据后,EntityConnection 验证概念性模型、存储模型和映射文件是否全部存在。When metadata is loaded, the EntityConnection verifies that the conceptual model, the storage model, and the mapping file are all present.

适用于