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数据库名称或连接字符串,或者没有向 DbContext 提供任何数据库名称或连接,在这种情况下,上下文类的名称将传递给此工厂,以便生成 DbConnection 时,将使用此名称。 默认情况下, IDbConnectionFactory 要使用的实例从 appSettings 中的“EntityFramework DefaultConnectionFactory”条目读取应用程序的 .config 文件。 如果在配置文件中找不到任何条目,则 SqlConnectionFactory 使用。 在代码中设置此属性始终会替代配置文件中找到的任何值。