简体   繁体   中英

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 .

I have just downgraded to .NET 4.0 as the server only has that for a maximum version. I don't have access to upgrade .NET framework version on server.

So, I have changed project properties to 4.0 and I am able to build.

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'.
at System.Data.Entity.Utilities.TypeExtensions.Assembly(Type type)
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.EnsureLoadedForContext(Type contextType) at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model) at

It looks like this is due to a fx 4.0 compatibility issue.

Please guide how I could resolve this?

If you use its NuGet package,

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.

Sorry, .NET 4.0 is deprecated and you shouldn't be using it for any production work. Either downgrade to .NET 3.5 SP 1 or upgrade to 4.5.x.

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