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)
從資料庫名稱或連接字串建立 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 要使用的實例會從 appSettings 中的 「EntityFramework DefaultConnectionFactory」 專案讀取應用程式的 .config 檔案。 如果在組態檔 SqlConnectionFactory 中找不到任何專案,則會使用 。 在程式碼中設定此屬性一律會覆寫組態檔中找到的任何值。