简体   繁体   English

使用EF 5(而不是4.x)

[英]Using EF 5 (and NOT 4.x)

I have now wasted a few days trying to get EF to work again. 我现在已经浪费了几天试图让EF重新工作。 From what I can tell, my project has some references to EF4 even though I have been trying to use EF5. 据我所知,即使我一直在尝试使用EF5,我的项目也有一些对EF4的引用。

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.) 有人可以指出我需要采取的所有步骤,以便从我的计算机中消除所有与EF4相关的开发参考(如果我有使用它的第三方.net应用程序,很好-我只是不想在我的任何开发中使用它) )

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. 现在,似乎没有任何作用,因为EF的2个版本似乎相互竞争-即使当我开始一个新项目时。

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"? 另外,如果我仅使用EF 5,则当我想创建新的EF类时,是否要使用“ ADO.NET实体数据模型”或“ 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... 我认为第一个似乎是第二个,似乎想创建一个tt文件,而不是edmx文件,但是我想我会检查一下,以防我遗漏了一些明显的东西...

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.) 我正在使用C#在运行VS 2012的Win 8系统上进行开发,并且正在编写一个大型桌面WPF应用程序(1个解决方案,许多项目,大量数据。)

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. FWIW-我当前无法使用的解决方案文件夹中的packages文件夹具有EntityFramework.5.0.0,因此我知道已经安装了EntityFramework.5,我只需要从它们继续感染我项目的位置消除EF 4.x引用。 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. 最糟糕的是,在某一时刻,它一切正常,没有问题-然后,我尝试通过Nu-Get重新安装EF 5来修复某些问题,此后一直没有任何效果。

Thanks 谢谢

Not sure if this is will solve your problem, but it might help... when you use nuget, it manipulates your solution: 不知道这是否可以解决您的问题,但可能会有所帮助...当您使用nuget时,它将操纵您的解决方案:

  • EF nuget package is added to the \\packages\\ folder in your solution root EF nuget软件包已添加到解决方案根目录的\\ packages \\文件夹中
  • A packages.config file is created for each project in the solution that you use nuget on 将在您使用nuget的解决方案中为每个项目创建一个packages.config文件
  • A reference is added in the project file (*.csproj For c#) 在项目文件中添加了参考(对于c#,*。csproj)

Sometimes you might need to change what nuget has done, and so you can check in these areas. 有时您可能需要更改nuget所做的事情,因此可以在这些区域中进行检查。 In your case you might be better off deleting both EF versions manually and then adding EF5 in using nuget or whatever method suits. 在您的情况下,最好手动删除两个EF版本,然后在使用nuget或任何适合的方法中添加EF5。

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). 听起来您可能已经删除了EF软件包,但没有整理package.config和项目文件,所以请先检查一下(在VS解决方案关闭时,您将要对其进行编辑)。

You're looking to remove lines starting <package id="EntityFramework"... from each packages.config file. 您正在寻找从每个packages.config文件中删除以<package id="EntityFramework"...开头的行。

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. 如果您希望从解决方案中完全删除nuget,则csproj文件具有带有<Content Include="packages.config" /><itemgroup> <Content Include="packages.config" /> -删除整个项目组,可能有其他对此文件的引用错过了,您也要删除它们。

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. 否则,如果您只是在删除EF内容之后,请查找具有您的引用的<itemgroup> ,并确保不存在不需要的EF版本的引用。

I think that's all you need - when you reload the solution in VS after making these changes, your references should come right. 我认为这就是您所需要的-在进行这些更改后在VS中重新加载解决方案时,您的引用应该正确。

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. 我从头开始创建了一个新的解决方案,并首先构建了EF项目,并确保它可以工作。 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.... 我真的希望MS有一个能够显示项目引用的所有程序集的工具-名称,程序集位置和引用该程序集的模块-这样就可以轻松解决这些问题。

Thanks again for all your help. 再次感谢你的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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