locked
Can DbContext and ObjectContext coexist in one project with EF 6 RRS feed

  • Question

  • I have a solutions with 3 projects that have been upgraded to EntityFramework 6.0.

    I folowed the instructions provided on this page http://msdn.microsoft.com/en-US/data/upgradeEF6

    There is no reference to EF 5 any more.

    I was using ObjectContext on all .edmx files, so I added "EF 6.x EntityObject Generator" template files to all .edmx files.

    The new context model added after upgrading to EF6 added the .tt that generate the DbContext object. That was what I wanted.

    No I have the following error: System.ArgumentException: Could not find the conceptual model type for 'CiaName.Admin.xxx'.

    Can both technologies (objectcontext and dbcontext) coexist in one project?

    I cannot find any place where the restriction is state for EF 6.

    Thanks for your help.

    Tuesday, June 3, 2014 11:55 AM

Answers

  • Yes, they can, DbContext is just "sugar coating" on top of ObjectContext.

    But it is unclear if you want to use DbContext or ObjectContext going forward.

    Julie Lerman has some upgrade tips in her MSDN magazine article here: http://msdn.microsoft.com/en-us/magazine/dn683792.aspx


    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    • Proposed as answer by Fred Bao Wednesday, June 4, 2014 1:24 AM
    • Marked as answer by Fred Bao Thursday, June 12, 2014 6:41 AM
    Tuesday, June 3, 2014 12:45 PM

All replies

  • Yes, they can, DbContext is just "sugar coating" on top of ObjectContext.

    But it is unclear if you want to use DbContext or ObjectContext going forward.

    Julie Lerman has some upgrade tips in her MSDN magazine article here: http://msdn.microsoft.com/en-us/magazine/dn683792.aspx


    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    • Proposed as answer by Fred Bao Wednesday, June 4, 2014 1:24 AM
    • Marked as answer by Fred Bao Thursday, June 12, 2014 6:41 AM
    Tuesday, June 3, 2014 12:45 PM
  • You can use both. They are not exclusive and DbContext does not replace ObjectContext. It is more of a wrapper around the ObjectContext and you can get to the ObjectContext from the DbContext (see here for more).
    Tuesday, June 3, 2014 12:47 PM