Issue when migrating from EF4.0 to EF5.0 to improve request performance on a TPT schema RRS feed

  • Question

  • I'm switching my project from VS2010 to VS2012 and .Net4.0 to .Net4.5.
    One goal of this migration (among others) is to take advantage of the major improvement in SQL generation with a TPT schema.

    I added EntityFramework 5 NuGet package to my VS2012/.Net4.5 project and recompiled the solution but I can't see any improvement in terms of request execution time. Actually, I managed to see that the generated request is exactly the same as the one generated before referenceing EF 5.0. I've been really disapointed to see during a debug session that EntityFramework.dll wasn't even loaded at runtime.

    With EF4.0, I had no configuration section in my app.config file and everything was initialized manually by code. the EF 5.0 NuGet package added some stuuf in app.config but it seems that it has no effect in my case.

    Am I missing something ?


    Thursday, February 14, 2013 4:10 PM

All replies

  • Hi Nicolas,

    Welcome to the MSDN forum.

    Please refer to  this article about how to upgrade existing projects to EF5:

    Please verify EntityFramework.dll version in all of the projects you update.

    Best Regards,

    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, February 15, 2013 7:25 AM
  • Hi Alexander and thanks for your help

    I've been reading this article several times these days but I couldn't find anything related to my issue.

    All projects that used to reference System.Data.Entity now also reference EntityFramework.dll version 5.0 (and not 4.4).
    Btw, as my code doesn't use  any type declared in EntityFramework.dll, the generated binaries don't actually reference EntityFramework.dll (I checked that with reflector). I guess that the configuration section and the associated settings should force EntityFramework.dll to be loaded. Am I right ? How could I make my software use the sql generator of EF5 instead of EF4 ?


    • Edited by Nicocous1 Tuesday, February 19, 2013 4:54 PM
    Friday, February 15, 2013 5:50 PM
  • I have actually one important question about my issue.

    Do I need to upgrade to EF 5.0 to take advantage of the new SQL generation code ? Is it provided by .Net 4.5 or EF 5.0 ?



    • Edited by Nicocous1 Monday, February 18, 2013 5:38 PM
    Monday, February 18, 2013 5:38 PM
  • Hi Nicolas,

    EF5 is composed of several components, some reside in the .NET framework and others come in the NuGet package. Yet a third aspect of EF5 is the designer that comes with Visual Studio.

    The SQL code generator in EF5 is located in System.Data.Entity.dll, part of the .NET framework. In essence, when you upgrade from .NET 4.0 to .NET 4.5, you are also upgrading from EF4 to EF5. The components that shipped in the NuGet package (EntityFramework.dll) are mostly related to the Code First pipeline and to the DbContext API. If your application wasn't using Code First or DbContext, then you don't need to reference EntityFramework.dll.

    There were some improvements done to the generation of SQL for TPT models in EF5, but these changes will only improve certain shapes of queries under certain circumstances; that is, not every single query to a TPT model will hit the improvements introduced in EF5, and apparently your code isn't benefiting form these.

    Improvement of this code path in EF is still a high priority to the team. See the EF wish list for more information on the different asks made by the community. Also, feel free to grab the latest copy of the Entity Framework source code from the EF codeplex site. We are always open to get contributions from the community.


    Wednesday, February 27, 2013 1:14 AM
  • Hello David, and thank you for your answer.

    It's really sad that the improvements in .Net 4.5 don't cover more use cases.
    Can we expecta better sql generation ith EF 6, without any update of .Net framework ?

    Thanks again for you support.

    Monday, April 8, 2013 10:42 AM