Freigeben über


Database.DefaultConnectionFactory-Eigenschaft

[Diese Seite bezieht sich auf Entity Framework Version 6. Die neueste Version ist als 'Entity Framework' NuGet-Paket verfügbar. Weitere Informationen zu Entity Framework finden Sie unter msdn.com/data/ef.]

Hinweis: Diese API ist mittlerweile veraltet.

Die Verbindungsfactory, die beim Erstellen einer DbConnection aus lediglich einem Datenbanknamen oder einer Verbindungszeichenfolge verwendet werden soll.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

Syntax

'Declaration
<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
'Usage
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)

Eigenschaftswert

Typ: System.Data.Entity.Infrastructure.IDbConnectionFactory

Hinweise

Wird verwendet, wenn für DbContext lediglich ein Datenbankname oder eine Verbindungszeichenfolge angegeben wird oder wenn für DbContext kein Datenbankname oder keine Verbindung gegeben angegeben wird. In diesem Fall wird der Name der Kontextklasse an diese Factory übergeben, um eine DbConnection zu generieren. Standardmäßig wird die zu verwendende IDbConnectionFactory-Instanz in der CONFIG-Datei der Anwendung unter appSettings im Eintrag "EntityFramework DefaultConnectionFactory" gelesen. Wenn kein Eintrag in der Konfigurationsdatei gefunden wird, wird SqlConnectionFactory verwendet. Durch das Festlegen dieser Eigenschaft in Code wird jeder Wert überschrieben, der in der Konfigurationsdatei gefunden wird.

Siehe auch

Verweis

Database Klasse

System.Data.Entity-Namespace