Database.DefaultConnectionFactory 屬性
[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]
注意:這個 API 現在已經過時。
單僅從資料庫名稱或連接字串建立 DbConnection 時所要使用的連接工廠。
命名空間: System.Data.Entity
組件: EntityFramework (在 EntityFramework.dll 中)
語法
'宣告
<ObsoleteAttribute("The default connection factory should be set in the config file or using the DbConfiguration class. (See https://go.microsoft.com/fwlink/?LinkId=260883)")> _
Public Shared Property DefaultConnectionFactory As IDbConnectionFactory
Get
Set
'用途
Dim value As IDbConnectionFactory
value = Database.DefaultConnectionFactory
Database.DefaultConnectionFactory = value
[ObsoleteAttribute("The default connection factory should be set in the config file or using the DbConfiguration class. (See https://go.microsoft.com/fwlink/?LinkId=260883)")]
public static IDbConnectionFactory DefaultConnectionFactory { get; set; }
[ObsoleteAttribute(L"The default connection factory should be set in the config file or using the DbConfiguration class. (See https://go.microsoft.com/fwlink/?LinkId=260883)")]
public:
static property IDbConnectionFactory^ DefaultConnectionFactory {
IDbConnectionFactory^ get ();
void set (IDbConnectionFactory^ value);
}
[<ObsoleteAttribute("The default connection factory should be set in the config file or using the DbConfiguration class. (See https://go.microsoft.com/fwlink/?LinkId=260883)")>]
static member DefaultConnectionFactory : IDbConnectionFactory with get, set
static function get DefaultConnectionFactory () : IDbConnectionFactory
static function set DefaultConnectionFactory (value : IDbConnectionFactory)
屬性值
類型:System.Data.Entity.Infrastructure.IDbConnectionFactory
備註
其使用時機為:只提供資料庫名稱或連接字串給 DbContext 或未提供任何資料庫名稱或連接給 DbContext 時,而在這類情況下會將內容類別的名稱傳遞給此工廠以便產生 DbConnection。 預設所使用的 IDbConnectionFactory 執行個體是讀取自應用程式的 .config 檔案,從 appSettings 內的 "EntityFramework DefaultConnectionFactory" 項目取得。 若在組態檔中找不到該項目,則會使用 SqlConnectionFactory。 由程式碼內設定此屬性一律會覆寫任何在組態檔中找到的值。