简体   繁体   中英

how to use EF 6.0 with net 4.0?

I am using VS2013 and I have a project which target is 4.0. I have installed from the nuget the entity framework, that is the version 6.0.1.

The next tep is to create the edmx from the sql server. In the wizard, there is a screen that show two options, use EF 6.0 or 5.0. The option 6.0 is disalbed and I only can select 5.0. I have a message that says that my project has a reference to an earlier version of EF, that I have to exit from the wizard and update before contiue with the process.

I delete the references to EntityFramework and EntityFramework.SqlServer and I added it manually from the package folder that was created when I installed EF 6.0 from the nuget.

I try to create again the edmx but the problem persists.

If I delete the two references and I try to create the edmx, I can select the 6.0 version of EF, but later I can't see the edmx because I get an error that says:

"The entity model designer is unable to display the file you requested"

I thought that with VS2013 I can to use EF 6.0 with a 4.0 project without do any special configuration.

Can I generate a edmx model and use EF 6.0 wiht a 4.0 project? How?

Thanks.

You can use EF 6 with a .NET 4.0 project. I use it myself (but with VS2012).

Did you try to delete EF from your solution with NuGet, clean your solution and install EF 6.0 again?

You can't use EF 5.0 with .NET 4.0 because EF5 has a dependency on System.Data.Entity.dll that is part of the .NET Framework version. Entity Framework 6.0 doesn't has this dependency, the dll is included in this version.

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