Database.DefaultConnectionFactory 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
The default connection factory should be set in the config file or using the DbConfiguration class. (See http://go.microsoft.com/fwlink/?LinkId=260883)
連線工廠在建立 A 時DbConnection,只需從資料庫名稱或 連接字串 即可。
public static System.Data.Entity.Infrastructure.IDbConnectionFactory DefaultConnectionFactory { get; set; }
[System.Obsolete("The default connection factory should be set in the config file or using the DbConfiguration class. (See http://go.microsoft.com/fwlink/?LinkId=260883)")]
public static System.Data.Entity.Infrastructure.IDbConnectionFactory DefaultConnectionFactory { get; set; }
member this.DefaultConnectionFactory : System.Data.Entity.Infrastructure.IDbConnectionFactory with get, set
Public Shared Property DefaultConnectionFactory As IDbConnectionFactory
屬性值
- 屬性
備註
當僅給資料庫DbContext名稱或 連接字串 給予 DbContext,或是沒有資料庫名稱或連線時,會將上下文類別的名稱傳給該工廠以產生 DbConnection。 預設情況下, IDbConnectionFactory 要使用的實例是從應用程式的 .config 檔案讀取,該檔案來自 appSettings 中的「EntityFramework DefaultConnectionFactory」項目。 如果設定檔找不到相關條目,則 SqlConnectionFactory 會使用。 在程式碼中設定這個屬性,總是會覆蓋設定檔中找到的任何值。