共用方式為


EntityConnection 建構函式

定義

初始化 EntityConnection 類別的新執行個體。

多載

名稱 Description
EntityConnection()

初始化 EntityConnection 類別的新執行個體。

EntityConnection(String)

根據連接字串初始化 EntityConnection 類別的新執行個體。

EntityConnection(MetadataWorkspace, DbConnection)

使用指定的 EntityConnectionMetadataWorkspace 初始化 DbConnection 類別的新執行個體。

備註

若要避免不小心讓類似 System.Data.Common.CommandTreesObjectContext 等物件與其中繼資料未同步,EntityConnection 必須鎖定它的中繼資料。 當鎖定中繼資料以後,就不允許對連接字串做任何變更。 以下是鎖定中繼資料的兩個案例:

當載入中繼資料時,EntityConnection 會驗證概念模型、儲存模型及對應檔是否都存在。

如需程式代碼範例,請參閱 使用 EntityClient

EntityConnection()

初始化 EntityConnection 類別的新執行個體。

public:
 EntityConnection();
public EntityConnection();
Public Sub New ()

備註

若要避免不小心讓類似 System.Data.Common.CommandTreesObjectContext 等物件與其中繼資料未同步,EntityConnection 必須鎖定它的中繼資料。 當鎖定中繼資料以後,就不允許對連接字串做任何變更。 以下是鎖定中繼資料的兩個案例:

當載入中繼資料時,EntityConnection 會驗證概念模型、儲存模型及對應檔是否都存在。

如需程式代碼範例,請參閱 使用 EntityClient

適用於

EntityConnection(String)

根據連接字串初始化 EntityConnection 類別的新執行個體。

public:
 EntityConnection(System::String ^ connectionString);
public EntityConnection(string connectionString);
new System.Data.EntityClient.EntityConnection : string -> System.Data.EntityClient.EntityConnection
Public Sub New (connectionString As String)

參數

connectionString
String

提供者特定連接字串。

例外狀況

已提供無效的連接字串關鍵字,或尚未提供必要的連接字串關鍵字。

備註

實體數據模型工具會產生儲存在應用程式組態檔中的具名連接字串。 當您具現化 EntityConnection 類別時,可以提供這個具名連接字串來取代 connectionString 參數。

若要避免不小心讓 System.Data.Common.CommandTreesObjectContext 物件與其中繼資料未同步,EntityConnection 必須鎖定它的中繼資料。 當鎖定中繼資料以後,就不允許對連接字串做任何變更。 以下是鎖定中繼資料的兩個案例:

當載入中繼資料時,EntityConnection 會驗證概念模型、儲存模型及對應檔是否都存在。

如需程式代碼範例,請參閱 使用 EntityClient

適用於

EntityConnection(MetadataWorkspace, DbConnection)

使用指定的 EntityConnectionMetadataWorkspace 初始化 DbConnection 類別的新執行個體。

public:
 EntityConnection(System::Data::Metadata::Edm::MetadataWorkspace ^ workspace, System::Data::Common::DbConnection ^ connection);
public EntityConnection(System.Data.Metadata.Edm.MetadataWorkspace workspace, System.Data.Common.DbConnection connection);
new System.Data.EntityClient.EntityConnection : System.Data.Metadata.Edm.MetadataWorkspace * System.Data.Common.DbConnection -> System.Data.EntityClient.EntityConnection
Public Sub New (workspace As MetadataWorkspace, connection As DbConnection)

參數

workspace
MetadataWorkspace

與這個 MetadataWorkspace 相關聯的 EntityConnection

connection
DbConnection

這個 EntityConnection 物件的基礎資料來源連接。

例外狀況

workspaceconnection 參數為 null

工作區中遺漏概念模型。

-或-

工作區中遺漏對應檔。

-或-

工作區中遺漏儲存模型。

-或-

connection 不是關閉的狀態。

connection 不是來自於 ADO.NET Entity Framework 相容的提供者。

備註

此建構函式可讓您從不是檔案或磁碟內的中繼資料或是從組件 (Assembly) 內的內嵌資源來建立 EntityConnection

若要避免不小心讓類似 System.Data.Common.CommandTreesObjectContext 等物件與其中繼資料未同步,EntityConnection 必須鎖定它的中繼資料。 當鎖定中繼資料以後,就不允許對連接字串做任何變更。 以下是鎖定中繼資料的兩個案例:

當載入中繼資料時,EntityConnection 會驗證概念模型、儲存模型及對應檔是否都存在。

適用於