Hi, We have recently upgraded our projects from EF 4.3 to EF 6. All seems to be fine except Dynamic Data project. EF model entities are used ObjectContext (not DBContext). I followed the steps you mentioned in this page and also referred the below url.
Im getting error 'cannot implicitly convert type 'MyEntities' to system.data.entity.dbcontext' in the below line which is in Global.asax.
DefaultModel.RegisterContext(
new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(() => new MyEntities()),
new ContextConfiguration { ScaffoldAllTables = true });
I know system not allowing to convert from ObjectContext to DBContext. Do you have any suggestions to register ObjectContext Entities?
I'm getting "The context type 'MyEntities' is not supported" error if I try the below one:
DefaultModel.RegisterContext(
() =>
{
var context = ((IObjectContextAdapter)new MyEntities()).ObjectContext;
return context;
},
new ContextConfiguration() { ScaffoldAllTables = true });
Hi jjayshaa
In Entity Framework 6 the default code generator was changed to generate POCO entities and DBContext as opposed to entities derived from EntityObject and ObjectContext which was the default in Entity Framework 4.
I suggest you change your code to welcome changes.
Or you could reverting to ObjectContext in EF Designer, link below is for your reference. https://msdn.microsoft.com/en-us/data/jj556581.aspx
Hoping my reply could be helpful to you.
Best Regards,
Wang Li
None
0 Points
2 Posts
Register ObjectContext in EF6 - Dynamic Data
Jun 17, 2015 05:32 PM|jjayshaa|LINK
Hi, We have recently upgraded our projects from EF 4.3 to EF 6. All seems to be fine except Dynamic Data project. EF model entities are used ObjectContext (not DBContext). I followed the steps you mentioned in this page and also referred the below url.
http://blogs.msdn.com/b/webdev/archive/2014/02/28/announcing-the-release-of-dynamic-data-provider-and-entitydatasource-control-for-entity-framework-6.aspx
Im getting error 'cannot implicitly convert type 'MyEntities' to system.data.entity.dbcontext' in the below line which is in Global.asax.
DefaultModel.RegisterContext(
new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(() => new MyEntities()),
new ContextConfiguration { ScaffoldAllTables = true });
I know system not allowing to convert from ObjectContext to DBContext. Do you have any suggestions to register ObjectContext Entities?
I'm getting "The context type 'MyEntities' is not supported" error if I try the below one:
DefaultModel.RegisterContext(
() =>
{
var context = ((IObjectContextAdapter)new MyEntities()).ObjectContext;
return context;
},
new ContextConfiguration() { ScaffoldAllTables = true });
Thanks
Star
9859 Points
974 Posts
Re: Register ObjectContext in EF6 - Dynamic Data
Jun 18, 2015 05:27 AM|Li Wang|LINK
Hi jjayshaa
In Entity Framework 6 the default code generator was changed to generate POCO entities and DBContext as opposed to entities derived from EntityObject and ObjectContext which was the default in Entity Framework 4.
I suggest you change your code to welcome changes.
Or you could reverting to ObjectContext in EF Designer, link below is for your reference.
https://msdn.microsoft.com/en-us/data/jj556581.aspx
Hoping my reply could be helpful to you.
Best Regards,
Wang Li
Member
1 Points
21 Posts
Re: Register ObjectContext in EF6 - Dynamic Data
Jun 25, 2015 07:00 PM|dblwizard|LINK
Li Wang,
Can you point to a current walk through for this "new" code generation? I'm trying to use EF and Dynamic Data to generate a simple administration website and all the walk throughs I can find are for EF 5 or previous. I found this site http://blogs.msdn.com/b/webdev/archive/2014/02/28/announcing-the-release-of-dynamic-data-provider-and-entitydatasource-control-for-entity-framework-6.aspx but it only has C# code and I'm struggling to translate the RegisterContext syntax into VB.net. I have a pre existing project that was written in VB.Net and have that as a requirement.
I also found this page that states the initial provider in Feb 2014 was not compatible with VB.net - http://www.c-sharpcorner.com/UploadFile/4b0136/getting-started-with-preview-of-dynamic-data-and-entity-data/ and have not been able to confirm if this is or is not still true.
Thanks
David
Star
9859 Points
974 Posts
Re: Register ObjectContext in EF6 - Dynamic Data
Jun 26, 2015 05:42 AM|Li Wang|LINK
Hi dblwizard,
You could follow the link, if you have more question when writting demo, please create a new thread.
More forum members will see your new thread and help you.
Best Regards,
Wang Li