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

asp.net c# entity-framework objectcontext

Question

I have a new project created using Visual Studio 2013 with an ADO.NET Entity Data Model (EF6).

Now I have to use some Dynamic Data function (like access to MetaTable object), so I add this code:

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)

1
5
12/11/2013 9:27:40 PM

Accepted Answer

A new preview of Dynamic Data Provider and EntityDataSource control for EF6 has been released. Please check this out, it worked for me.

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

To register the provider:

MetaModel model = new MetaModel();
model.RegisterContext(
    new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(
       () => new KiwiJuiceEntities()
    ),
    new ContextConfiguration() { ScaffoldAllTables = true }
);     
8
8/25/2015 2:35:28 PM

Popular Answer

DynamicData do no support EntityFramework 6 yet so downgrading to EF 5 'solve' the problem.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow