简体   繁体   中英

Mixing .NET Core and Framework in same solution - System.Data.Entity Issue

I am giving our legacy .NET 4 Framework libraries a new entry via .NET Core WebAPIs. Unfortunately, I am stuck at an issue at runtime (while loading dependency container) in the webapi project (net core):

FileNotFoundException: Could not load file or assembly 'System.Data.Entity'

I tried explicitly adding reference to Entity in webapi project but then I get BadImageReferenceException, I am aware this library is discontinued in net core.

The Legacy .NET 4 Framework library has extensive use of EntityFramework (5.0.0) so System.Data.Entity is heavily used. I tried to port these libraries to .netstandard but a lot of code change is required.

Any options I have to avoid (heavy) code change where I can use the shiny new api in core and supporting libraries untouched?

EF5 is not compatible with.Net Core. The only classic EF version that runs on.Net Core is Entity Framework 6 since Version 6.3 :

  • Support for .NET Core 3.0
    The EntityFramework package now targets .NET Standard 2.1 in addition to .NET Framework 4.x.

So update from EF5 to EF6 to fix your issues.

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