EF 6 System.Data.Objects.ObjectContext错误 [英] EF 6 System.Data.Objects.ObjectContext Error

查看:344
本文介绍了EF 6 System.Data.Objects.ObjectContext错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

近日笔者从实体框架5升级到实体框架6阿尔法2,我收到以下错误:

I recently upgraded from Entities Framework 5 to Entities Framework 6 Alpha 2 and I am getting the following error:

找不到方法:System.Data.Objects.ObjectContext
  System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'。

Method not found: 'System.Data.Objects.ObjectContext System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()'.

当我打电话这击中

if (Membership.ValidateUser(model.UserName, model.Password)) {}

这使用前不知道做工精细,为什么它雨后春笋此错误。有什么建议?

This used to work fine before not sure why it's springing this error. Any suggestions?

推荐答案

EF 6没有 System.Data.Objects.ObjectContext 。 EF 6已经移动了一些类型,​​包括的ObjectContext ,从 System.Data.Entity.dll EntityFramework.dll ,并改变了他们的命名空间。你得到这个错误的事实表明你还没有尝试重新编译应用程序,你只需更换 EntityFramework.dll 和最好的希望。这是行不通的。您需要更新您的code。与EF 6的工作:您需要删除您引用 System.Data.Entity.dll ,并更新code以引用的新类型。

EF 6 does not have System.Data.Objects.ObjectContext. EF 6 has moved some types, including ObjectContext, from System.Data.Entity.dll into EntityFramework.dll, and changed their namespaces. The fact that you get this error suggests you haven't attempted to recompile your application, you've simply replaced EntityFramework.dll and hoped for the best. That won't work. You need to update your code to work with EF 6: you need to remove your references to System.Data.Entity.dll, and update your code to refer to the new types.

这也许会为参照 IObjectContextAdapter.ObjectContext 属性是在你使用某些库是可能的,但它很可能会在你自己code。错误信息(在部分你没有在你的问题包括)应该告诉你,它是从哪里过来。

It just might be possible for the reference to the IObjectContextAdapter.ObjectContext property to be in some library you're using, but most likely it'll be in your own code. The error message (in the part you didn't include in your question) should tell you where it is coming from.

这篇关于EF 6 System.Data.Objects.ObjectContext错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆