简体   繁体   English

实体框架6.1.2是否支持.NET Framework 4.0?

[英]Entity framework 6.1.2 support for .NET framework 4.0?

My application was created in .NET fx 4.5 and it was using Entity Framework 6.1.2 . 我的应用程序是在.NET fx 4.5创建的,并且使用的是Entity Framework 6.1.2

I have just downgraded to .NET 4.0 as the server only has that for a maximum version. 我刚刚降级为.NET 4.0,因为服务器仅具有最高版本。 I don't have access to upgrade .NET framework version on server. 我无权在服务器上升级.NET Framework版本。

So, I have changed project properties to 4.0 and I am able to build. 因此,我将项目属性更改为4.0,并且能够构建。

Now my problem is, after deploying my application to the server, I'm getting the below error: 现在我的问题是,将应用程序部署到服务器后,出现以下错误:

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Reflection.IntrospectionExtensions' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 未处理的异常:System.TypeLoadException:无法从程序集“ mscorlib,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089”中加载类型“ System.Reflection.IntrospectionExtensions”。
at System.Data.Entity.Utilities.TypeExtensions.Assembly(Type type) 在System.Data.Entity.Utilities.TypeExtensions.Assembly(类型类型)
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForContext(Type contextType) at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model) at 位于System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection,DbCompiledModel模型)处的System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForContext(Type contextType)

It looks like this is due to a fx 4.0 compatibility issue. 看来这是由于fx 4.0兼容性问题所致。

Please guide how I could resolve this? 请指导我如何解决此问题?

If you use its NuGet package, 如果您使用其NuGet软件包,

https://www.nuget.org/packages/EntityFramework https://www.nuget.org/packages/EntityFramework

Make sure after changing target framework version you uninstall and install it again. 确保在更改目标框架版本后,您卸载并重新安装它。 That forces NuGet to add the .NET 4.0 references to your project, instead of the .NET 4.5 ones. 这迫使NuGet将.NET 4.0引用而不是.NET 4.5引用添加到您的项目中。

Sorry, .NET 4.0 is deprecated and you shouldn't be using it for any production work. 抱歉,.NET 4.0已过时,您不应在任何生产工作中使用它。 Either downgrade to .NET 3.5 SP 1 or upgrade to 4.5.x. 降级到.NET 3.5 SP 1或升级到4.5.x。

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

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