We are trying to replace our current REST API ( built using .net framework ) with .Net Core Rest API. But instead of converting/writing all the Business logic in .net core\standard. We're thinking to use the existing DLLs that were built using.net framework 4.6.
To implement this:
[HttpGet]
public IActionResult Get()
{
// connectionString is intialized in the constructor
var allData = new MyBusinessLayer(connectionString).ListAllData();
return Ok();
}
"ListAllData" method reads the data from the database, applies some business rules and returns the data.
Above code compiles without any error but when I run the the service, it throws this error:
FileNotFoundException: Could not load file or assembly System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;. The system cannot find the file specified.
As my Business class is using System.Data.Entity assembly. I have tried adding the DLL reference to .net core project but then it threw a different error
BadImageFormatException: Could not load file or assembly System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
How can I resolve this issue Or what I am trying to do here is not currently possible ?
User contributions licensed under CC BY-SA 3.0