Installing Entity Framework 4.2 in VS2010

2019-08-24 02:17发布

问题:

Entity Framework templates and menu items generate errors in Visual Studio 2010 Ultimate on 64-bit XP.

The "Reverse Engineer Code First" menu item in Visual Studio tells me that version 4.0.0.0 of System.Data.Entity.dll cannot be found in the GAC, as do the item templates.

I have run the 4.1 msi, and the 4.2 nuget. As a result I have versions of the dll in the following 7 locations:

  • Windows\Microsoft.NET\Framework\v4.0.30319\
  • Windows\Microsoft.NET\Framework64\v4.0.30319\
  • Windows\Microsoft.NET\assembly\GAC_MSIL\policy.4.0.system.data.entity\v4.0_0.0.0__b77a5c561934e089\
  • Program Files\Reference Assemblies\Microsoft\Framework\v3.5\
  • Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\
  • Program Files (x86)\Reference Assemblies\Microsoft.NetFramework\v4.0\
  • Program Files (x86)\Reference Assemblies\Microsoft.NetFramework\v4.0\Profile\Client\

Anyone have any suggestions? Seems to me "Microsoft's recommended data access technology for new applications" should not be so difficult to install.

回答1:

Entity framework 4.0 (System.Data.Entity.dll) is part of .NET 4.0. There is no separate download. EF 4.1 ad EF 4.2 are distribution of EntityFramework.dll (not System.Data.Entity.dll). EF 4.2 is only distributed as NuGet and is not installed to GAC.

Reverse Engineer Code First is not part of any of these tools. It is part of EF Power Tools CTP 1 which is most probably dependent on EF 4.1 (it was released prior to EF 4.2 and there is possibility that it doesn't work with EF 4.2). This tool itself has no relation to functionality of Entity framework.



回答2:

Install EF6 or so using the nuget command line tool. Then in youe msvs solution explorer Add Reference, Browse to the C:\Workplace\C:\Workplace\EntityFramework.6.1.3\lib\net45 then add the .dll, either *SQLEntityFramework.dll or *EntityFramework.dll file.