I have a new project created using Visual Studio 2013 with an ADO.NET Entity Data Model (EF6).
我有一个使用Visual Studio 2013和ADO创建的新项目。NET实体数据模型(EF6)。
Now I have to use some Dynamic Data function (like access to MetaTable object), so I add this code:
现在我需要使用一些动态数据函数(比如访问MetaTable对象),所以我添加了以下代码:
MetaModel model = new MetaModel();
model.RegisterContext(() =>
{
return ((System.Data.Entity.Infrastructure.IObjectContextAdapter)new KiwiJuiceEntities()).ObjectContext;
}, new ContextConfiguration() { ScaffoldAllTables = true });
but I've got this error:
但我犯了一个错误:
Type of context 'System.Data.Entity.Core.Objects.ObjectContext' is not supported
Note that the project have the reference updated to EF6 (system.data.entity.core)
注意,该项目将引用更新为EF6 (system.data.entity.core)
3 个解决方案
#1
8
A new preview of Dynamic Data Provider and EntityDataSource control for EF6 has been released. Please check this out, it worked for me.
最新的EF6动态数据提供程序和EntityDataSource控件预览版已经发布。请检查一下,它对我有用。
http://blogs.msdn.com/b/webdev/archive/2014/01/30/announcing -预览- -动态数据的提供者和entitydatasource -控制-实体框架- 6. - aspx #
To register the provider:
注册供应商:
MetaModel model = new MetaModel();
model.RegisterContext(
new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(
() => new KiwiJuiceEntities()
),
new ContextConfiguration() { ScaffoldAllTables = true }
);
#2
4
DynamicData do no support EntityFramework 6 yet so downgrading to EF 5 'solve' the problem.
动态数据还不支持EntityFramework 6,因此降级为EF 5 'solve这个问题。
#3
3
Yes.
是的。
EF 6 does not have
System.Data.Objects.ObjectContext
. EF 6 has moved some types, includingObjectContext
, fromSystem.Data.Entity.dll
intoEntityFramework.dll
, and changed their namespaces. The fact that you get this error suggests you haven't attempted to recompile your application, you've simply replacedEntityFramework.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 toSystem.Data.Entity.dll
, and update your code to refer to the new types.EF 6没有System.Data.Objects.ObjectContext。EF 6已经从System.Data.Entity移动了一些类型,包括ObjectContext。EntityFramework dll。并更改它们的名称空间。您得到这个错误的事实表明您没有试图重新编译应用程序,您只是替换了EntityFramework。dll和希望的最好。是行不通的。要使用EF 6,需要更新代码:需要删除对System.Data.Entity的引用。dll,并更新您的代码以引用新的类型。
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.对IObjectContextAdapter的引用可能是可行的。ObjectContext属性应该位于正在使用的某个库中,但它很可能位于您自己的代码中。错误消息(在您的问题中没有包含的部分)应该告诉您它来自哪里。
References:
引用:
- EF 6 System.Data.Objects.ObjectContext Error
- EF 6 System.Data.Objects。ObjectContext的错误
- http://msdn.microsoft.com/en-US/data/dn469466
- http://msdn.microsoft.com/en-US/data/dn469466
- http://support.microsoft.com/kb/2816241
- http://support.microsoft.com/kb/2816241
#1
8
A new preview of Dynamic Data Provider and EntityDataSource control for EF6 has been released. Please check this out, it worked for me.
最新的EF6动态数据提供程序和EntityDataSource控件预览版已经发布。请检查一下,它对我有用。
http://blogs.msdn.com/b/webdev/archive/2014/01/30/announcing -预览- -动态数据的提供者和entitydatasource -控制-实体框架- 6. - aspx #
To register the provider:
注册供应商:
MetaModel model = new MetaModel();
model.RegisterContext(
new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(
() => new KiwiJuiceEntities()
),
new ContextConfiguration() { ScaffoldAllTables = true }
);
#2
4
DynamicData do no support EntityFramework 6 yet so downgrading to EF 5 'solve' the problem.
动态数据还不支持EntityFramework 6,因此降级为EF 5 'solve这个问题。
#3
3
Yes.
是的。
EF 6 does not have
System.Data.Objects.ObjectContext
. EF 6 has moved some types, includingObjectContext
, fromSystem.Data.Entity.dll
intoEntityFramework.dll
, and changed their namespaces. The fact that you get this error suggests you haven't attempted to recompile your application, you've simply replacedEntityFramework.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 toSystem.Data.Entity.dll
, and update your code to refer to the new types.EF 6没有System.Data.Objects.ObjectContext。EF 6已经从System.Data.Entity移动了一些类型,包括ObjectContext。EntityFramework dll。并更改它们的名称空间。您得到这个错误的事实表明您没有试图重新编译应用程序,您只是替换了EntityFramework。dll和希望的最好。是行不通的。要使用EF 6,需要更新代码:需要删除对System.Data.Entity的引用。dll,并更新您的代码以引用新的类型。
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.对IObjectContextAdapter的引用可能是可行的。ObjectContext属性应该位于正在使用的某个库中,但它很可能位于您自己的代码中。错误消息(在您的问题中没有包含的部分)应该告诉您它来自哪里。
References:
引用:
- EF 6 System.Data.Objects.ObjectContext Error
- EF 6 System.Data.Objects。ObjectContext的错误
- http://msdn.microsoft.com/en-US/data/dn469466
- http://msdn.microsoft.com/en-US/data/dn469466
- http://support.microsoft.com/kb/2816241
- http://support.microsoft.com/kb/2816241