Share via


Database.DefaultConnectionFactory Property

Definition

Caution

The default connection factory should be set in the config file or using the DbConfiguration class. (See http://go.microsoft.com/fwlink/?LinkId=260883)

The connection factory to use when creating a DbConnection from just a database name or a connection string.

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

Property Value

Attributes

Remarks

This is used when just a database name or connection string is given to DbContext or when the no database name or connection is given to DbContext in which case the name of the context class is passed to this factory in order to generate a DbConnection. By default, the IDbConnectionFactory instance to use is read from the application's .config file from the "EntityFramework DefaultConnectionFactory" entry in appSettings. If no entry is found in the config file then SqlConnectionFactory is used. Setting this property in code always overrides whatever value is found in the config file.

Applies to