EntityFramework 5 use dll version 4.4.0.instead 5.

2019-02-02 20:04发布

问题:

I have project based on .NET 4.0 but I need to use EntityFramework 5 in my solution. So I install it from the NuGet.

After that I change target framework to .NET 4.5 (I'm using VS 2012) and rebuild project.

But in reference folder I see that project use EntityFramework.dll version 4.4.0.0.

Ho can I use newer version of EntityFramework?

in web.config

<compilation debug="true" targetFramework="4.5">
    <assemblies>
       <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </assemblies>
</compilation>

回答1:

Newer version (the real EF5) is dependent on .NET 4.5. If you have added EF5 when your project was based on .NET 4.0 you will have only EF 4.4 (EF5 version without features dependent on .NET 4.5). After upgrading to EF 5.0 you need to update EntityFramework package. You can try to use Update-Package command. If it doesn't help you will need to uninstall package first and than add it again.