2013-12-11 22 views
5

私は、ADO.NETエンティティデータモデル(EF6)でVisual Studio 2013を使用して作成された新しいプロジェクトを持っています。EF6コンテキスト 'System.Data.Entity.Core.Objects.ObjectContext'のタイプはサポートされていません

今私は(メタテーブルオブジェクトへのアクセスなど)いくつかの動的データ機能を使用する必要がありますので、私はこのコードを追加:

MetaModel model = new MetaModel(); 
     model.RegisterContext(() => 
     { 
      return ((System.Data.Entity.Infrastructure.IObjectContextAdapter)new KiwiJuiceEntities()).ObjectContext; 
     }, new ContextConfiguration() { ScaffoldAllTables = true }); 

が、私はこのエラーを持っている:

Type of context 'System.Data.Entity.Core.Objects.ObjectContext' is not supported 

注意をプロジェクトがEF6(system.data.entity.core)に更新された参照を持っていることを確認してください。

答えて

8

EF6のDynamic Data ProviderおよびEntityDataSourceコントロールの新しいプレビューがリリースされました。これをチェックしてください、それは私のために働いた。

http://blogs.msdn.com/b/webdev/archive/2014/01/30/announcing-preview-of-dynamic-data-provider-and-entitydatasource-control-for-entity-framework-6.aspx#

プロバイダを登録するには:

MetaModel model = new MetaModel(); 
model.RegisterContext(
    new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(
     () => new KiwiJuiceEntities() 
    ), 
    new ContextConfiguration() { ScaffoldAllTables = true } 
);  
3

はい。

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.

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.

参考文献:

+0

私は、エラーレポートに正しい名前空間に注意し、古い参照を持っていない:System.Data.Entity.Core.Objects.ObjectContextを.. 。 – gidanmx2

+0

はい、私は見る!私はちょうど見落とした!お詫び! –

4

DynamicDataので問題 'を解決する' EF 5にダウングレードまだサポートEntityFramework 6を​​行いません。

+0

あなたはどのようにして「EF5にダウングレード」しましたか? –

+1

アンインストールパッケージEntityFramework -Force、インストールパッケージEntityFramework -Version 5.0.0参照:http://stackoverflow.com/questions/10206090/how-to-install-an-older-version-of-package-via-nuget – gidanmx2

+0

現時点でサポートされています:http://stackoverflow.com/a/22016040/842935 – danihp

関連する問題