Condividi tramite


Proprietà Database.DefaultConnectionFactory

[Questa pagina è specifica della versione 6 di Entity Framework. La versione più recente è disponibile come pacchetto NuGet per "Entity Framework". Per ulteriori informazioni su Entity Framework, vedere la pagina msdn.com/data/ef.]

Nota: questa API è ora obsoleta.

Factory di connessione da usare per la creazione di un oggetto DbConnection da un nome di database o una stringa di connessione.

Spazio dei nomi:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

Sintassi

'Dichiarazione
<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
'Utilizzo
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)

Valore proprietà

Tipo: System.Data.Entity.Infrastructure.IDbConnectionFactory

Note

Viene usato quando all'oggetto DbContext viene fornito solo un nome di database o una stringa di connessione oppure quando all'oggetto DbContext non viene fornito né un nome di database né una stringa di connessione, nel qual caso alla factory viene passato il nome della classe del contesto per generare un oggetto DbConnection. Per impostazione predefinita, l'istanza di IDbConnectionFactory da usare viene letta dal file di configurazione dell'applicazione dalla voce 'EntityFramework DefaultConnectionFactory' in appSettings. Se non viene trovata alcuna voce nel file di configurazione, viene usato SqlConnectionFactory. L'impostazione di questa proprietà nel codice comporta sempre l'override del valore trovato nel file di configurazione.

Vedere anche

Riferimento

Database Classe

Spazio dei nomi System.Data.Entity