[英]How to solve'System.Data.Entity.Database.DefaultConnectionFactory' is obsolete?
在以下行中使用Asp.Net MVC:
Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
我收到錯誤消息:
Warning as Error: 'System.Data.Entity.Database.DefaultConnectionFactory' is 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)'
怎么改呢?
從msdn鏈接復制
[ObsoleteAttribute("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 IDbConnectionFactory DefaultConnectionFactory { get; set; }
如果要使用配置文件設置DefaultConnectionFactory
則可以遵循此http://msdn.microsoft.com/zh-cn/data/jj556606.aspx
您需要將繼承自System.Data.Entity.DbConfiguration的類添加到DbContext類所駐留的程序集中。
在該類的構造函數中,添加以下調用:SetDefaultConnectionFactory(new SqlCeConnectionFactory(“ System.Data.SqlServerCe.4.0”));;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.