问题
Trying to use Visual Studio 2012, Entity Framework 5.0 database first approach to generate my edmx.
When I generate the EDMX from the database VS 2012 - says
Successfully registered the assembly 'System.Data.Entity, Version=4.0.0.0;
web.config
file as well says
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral.../>
I see
EntityFramework
andSystem.Data.Entity
both listed in the references.EntityFramework
shows up in the packages folder andSystem.Data.Entity
points to the .NET 4.5 install folder. Does this mean that I am succesfully using EF 5.0?For existing project migrations - when I migrate a project from VS 2010 .NET 4.0 and set the .NET client profile to 4.5 the
System.Data.Entity
assembly gets upgraded to the one in .NET 4.5 install folder. I do not see theEntityFramework.dll
at all. Are there any changes I would need to make in order for my existing project to mgirate to EF 5.0 and .NET 4.5
Am I missing something here?
回答1:
The version of System.Data.Entity.dll assembly is the same on both .NET Framework 4 and .NET Framework 4.5. The catch is that only one version can be installed on a machine at the same time so even if you target .NET Framework 4 in your project but run your app on a machine with .NET Framework 4.5 you will effectively run it against .NET Framework 4.5 (and therefore the EF5 version of System.Data.Entity.dll assembly). With regards to EntityFramework.dll - up to the version 6 it was build on top of System.Data.Entity.dll (in EF6 the code from System.Data.Entity.dll and EntityFramework.dll was merged and further evolved). If you used EntityFramework.dll in VS2010 it means that it had to be one of the 4.x versions which were EF4. You could continue to use it even with the EF5 version of System.Data.Entity.dll but you will not be able to take the advantage of new features introduced in EF5 (like enums, spatial etc.). Since you decided to move to .NET Framework 4.5/EF5 you should also update your EntityFramework.dll 5.0.0.0. To do that you have to install the NuGet extension (http://docs.nuget.org/docs/start-here/installing-nuget) if you have not already and just install EntityFramework.dll using the package manager console (http://www.nuget.org/packages/EntityFramework/5.0.0). It should replace the 4.x version you have in your project with 5.0.
来源:https://stackoverflow.com/questions/18208102/database-first-generation-entity-framework-5-system-data-entity-vs-entityframewo