I have these three projects:
Both 1 and 3 reference 2. I just replaced the old .NET Framework class library with a new one targeting .NET Standard. The class library uses the Microsoft.EntityFrameworkCore.Proxies
NuGet package.
Everything builds without error, my unit tests all run, and the ASP.NET Core app runs without issue. My problem is that the console application for updating the database builds, runs, but encounters a runtime error when it initializes the DbContext
on this line in the constructor:
ChangeTracker.LazyLoadingEnabled = false;
Saying that it cannot load the assembly Microsoft.EntityFrameworkCore.Proxies
. On investigation I found that the Microsoft.EntityFrameworkCore.Proxies.dll
file was not in the build output of the console application or the class library project. The only .dll in the output of the class library project was the project .dll itself, the old .NET Framework version had all the NuGet package .dlls in the output as well, and it ran fine using the database update tool.
Is there something extra that is necessary to include the dependencies in the output of a .NET Standard library?
Here is another suggestion, taken from CEZARY PIĄTEK's blog
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
</Project>
I ended up having to add .NET Framework 4.6.2 to the list of Target Frameworks for the class library.
In .csproj:
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
</PropertyGroup>
After this it works with a .NET Framework application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With