locked
Where is EF? RRS feed

  • Question

  • I am using VS 2012 and the first problem is that I cannot seem to find a reference to EF 5.0. My project is targeted to .NET 4.5 and another project in the solution indicates that I should add EF 5.0 to the references but I cannot find it anywhere (I looked in Assemblies -> Framework and Assemblies -> Extensions). So the one project where the reference was automatically added I removed it and looked again for it and I cannot find it. Now I am in worse trouble because I get errors that System.Data.Entity.Infrastructure does not exist and there is not such thing as DbContext etc. 

    On a side note it seems that something has changed with EF. Apparently you can no longer look at the code generated by EF. If you set 'Code Generation Strategy' to default you can see the code but then you get alot of duplicate definitions, so I put it back to 'None' and the duplicates went away.

    Thank you.


    Kevin Burton

    Wednesday, October 17, 2012 3:49 PM

Answers

  • I had this same problem. From what I saw when you add a edmx file to a project it does everything it needs to automatically, however if you want to reference that project from another one you have to install EF via NuGet in the second project.

    Under each project that I needed to access my data layer from I right clicked on the References section, and chose manage NuGet packages. Go to the Online section and choose the EntityFramework. If it is already installed you will see a green tick instead of a install button. After I did that everything worked and I was able to access my data layer from each project. (Assuming you have also added a reference to your data layer project as well)

    Victoria

    • Proposed as answer by Allen_MSDN Wednesday, October 24, 2012 2:19 AM
    • Marked as answer by KevinBurton Wednesday, October 24, 2012 3:05 AM
    Monday, October 22, 2012 8:57 AM

All replies

  • You can install EF 5 for a project via NuGet: http://nuget.org/packages/EntityFramework/


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, October 17, 2012 4:24 PM
  • Thank you. But when I when I go to manage NuGet properties it (VS 2012) indicates that EF is installed.


    Kevin Burton

    Wednesday, October 17, 2012 4:27 PM
  • Hi KevinBurton,

    Welcome to MSDN Forum.

    As @Reed said, you can install Entity Framework5.0 from NuGet, execute "install-package entityframework" in Package Manager Console. After that, all the references will auto add. If you're using database first, EF5.0 will generate code based on DbContext API for you. I suggest you to create a new project to test it, don't delete any references auto added.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, October 18, 2012 2:26 AM
  • So why isn't the EF available to Add Reference as System.Data or System.Configuration? I the reference does get removed (not by me because I have learned that it is not easy to get it back :() how do I add it back in? For projects that have an indirect need to add the reference, how do I add it there?

    I have some projects that give me a compile error indicating that I should add a reference to EF. But since EF doesn't seem to be available I don't know how to add it to that project. Ideas?

    Thank you.


    Kevin Burton

    Thursday, October 18, 2012 3:03 AM
  • Hi KevinBurton,

    You can try to execute "uninstall-package entityframework" in Package Manager Console and then execute "install-package entityframework" again.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, October 18, 2012 3:08 AM
  • Hi KevinBurton,

    Have you solved the issue? I look forward to hearing from you.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, October 22, 2012 2:10 AM
  • Thank you for your interest. No, I have not solved it yet. EF doesn't appear with any of the "normal" .net assemblies in VS 2012. Any suggestions for a work-around would be greatly appreciated.

    Kevin Burton

    Monday, October 22, 2012 3:36 AM
  • Hi KevinBurton,

    Please try to create a new project and install the Entity Framework, check if the assemblies loaded correctly.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, October 22, 2012 3:39 AM
  • I will certainly try a new project/solution. Isn't EF part of VS 2012? What Should I install? The problem that I ran into was I had a solution that had multiple projects in it. One of the projects referenced a project assembly that used EF but it didn't explicitly reference EF. When the solution built I got a build error that said I had to reference EF along with the reference to the project assembly. I started looking for EF and couldn't (and still cannot) find an EF assembly in the lists provided by VS. I will try to make another similar solution and see if I get a different result.

    Kevin Burton

    Monday, October 22, 2012 3:57 AM
  • I had this same problem. From what I saw when you add a edmx file to a project it does everything it needs to automatically, however if you want to reference that project from another one you have to install EF via NuGet in the second project.

    Under each project that I needed to access my data layer from I right clicked on the References section, and chose manage NuGet packages. Go to the Online section and choose the EntityFramework. If it is already installed you will see a green tick instead of a install button. After I did that everything worked and I was able to access my data layer from each project. (Assuming you have also added a reference to your data layer project as well)

    Victoria

    • Proposed as answer by Allen_MSDN Wednesday, October 24, 2012 2:19 AM
    • Marked as answer by KevinBurton Wednesday, October 24, 2012 3:05 AM
    Monday, October 22, 2012 8:57 AM