简体   繁体   中英

Using EF 5 (and NOT 4.x)

I have now wasted a few days trying to get EF to work again. From what I can tell, my project has some references to EF4 even though I have been trying to use EF5.

Can someone point me to whatever steps I need to do to just eliminate all development related references to EF4 from my computer (if I have 3rd party .net apps that use it, fine - I just don't want it in any of MY development.)

Right now, nothing is working as it appears that the 2 versions of EF are fighting with each other - even when I start with a new project.

Also, if I am just using EF 5, when I want to create a new EF class, would I be using "ADO.NET Entity Data Model" or "EF 5.x DbContext Generator"? I assume the first as the 2nd seems to want to create a tt file, not an edmx file, but thought I would check in case I was missing something obvious...

I am developing on a Win 8 system, running VS 2012, in C# and am writing a large desktop WPF app (1 solution, lots of projects, tons of data.)

FWIW - the packages folder in my currently non function solution folder has EntityFramework.5.0.0 so I know I have that installed, I just need to eliminate the EF 4.x references from wherever they keep infecting my project from. And yes, much of the time has been spent searching for an answer that will work - but none of the things I have found seem to allow it to work.

The worst part is that, at one point, it was all working without problem - and then I tried to fix something by re-installing EF 5 via Nu-Get and from then on, nothing has worked.

Thanks

Not sure if this is will solve your problem, but it might help... when you use nuget, it manipulates your solution:

  • EF nuget package is added to the \\packages\\ folder in your solution root
  • A packages.config file is created for each project in the solution that you use nuget on
  • A reference is added in the project file (*.csproj For c#)

Sometimes you might need to change what nuget has done, and so you can check in these areas. In your case you might be better off deleting both EF versions manually and then adding EF5 in using nuget or whatever method suits.

Sounds like you might have deleted the EF package, but not tidied up your packages.config and project files, so check there first (you'll want to edit them while your VS solution is closed).

You're looking to remove lines starting <package id="EntityFramework"... from each packages.config file.

If you are looking to remove nuget altogether from your solution, the csproj files have an <itemgroup> with <Content Include="packages.config" /> - delete the whole itemgroup, there might be other references to this file that I've missed and you'll want to remove them too.

Otherwise if you are just after removing the EF stuff, then look for the <itemgroup> that has your references, and make sure the reference for the unwanted EF version is not there.

I think that's all you need - when you reload the solution in VS after making these changes, your references should come right.

I have given up on this. It's just too much of a waste of time. I have started a new solution from scratch and built the EF project first and made sure it worked. That worked. So now I am systematically bringing in the other projects, backing up as I go, until I have all the other projects back in the new solution.

A big PITA. I really wish that MS had a tool that showed all the assemblies that were being referenced by a project - the name, assembly location, and module that was referencing it - so that it would be easy to fix these problems....

Thanks again for all your help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM