locked
Register ObjectContext in EF6 - Dynamic Data RRS feed

  • Question

  • User-1131120020 posted

    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

    Wednesday, June 17, 2015 5:32 PM

All replies