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

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

问题描述

我最近从实体框架 5 升级到实体框架 6 Alpha 2,但出现以下错误:

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

找不到方法:'System.Data.Objects.ObjectContextSystem.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 并希望最好.那行不通.您需要更新代码以使用 EF 6:您需要删除对 System.Data.Entity.dll 的引用,并更新您的代码以引用新类型.

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 属性的引用可能位于您正在使用的某个库中,但很可能位于您自己的代码中.错误消息(在您未包含在问题中的部分)应该告诉您它来自哪里.

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天全站免登陆