use*_*747 6 c# entity-framework-6
在我的MVC4应用程序中,我参考了我的EF模型组件.一切都很好.突然间,我开始收到以下错误消息.
The default DbConfiguration instance was used by the Entity Framework before the 'EFConfiguration' type was discovered. An instance of 'EFConfiguration' must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information.
Run Code Online (Sandbox Code Playgroud)
我正在使用EF 6.任何想法可能是什么原因?我仔细检查数据库并更新并与EF dll同步.
更新:当我尝试实例化Context对象时,我收到此错误
mEntities context = new Entities();
Run Code Online (Sandbox Code Playgroud)
谢谢
小智 0
您的问题可能是因为您的 DAL 中有一个类似此示例的类
public class EfConfiguration : DbConfiguration
Run Code Online (Sandbox Code Playgroud)
在这种情况下,您必须在 Global.asax 中使用 EF Context 之前对其进行初始化
参考值