2014-11-25 24 views
0

使用Asp.Net MVC在以下行:如何解決'System.Data.Entity.Database.DefaultConnectionFactory'已過時?

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

如何改寫呢?

回答

0

您需要將繼承自System.Data.Entity.DbConfiguration的類添加到您的DbContext類所在的程序集中。

在類的構造函數中添加調用: SetDefaultConnectionFactory(new SqlCeConnectionFactory(「System.Data.SqlServerCe.4.0」));

相關問題