System.IO.FileNotFoundException for Microsoft.EntityFrameworkCore

entity-framework-core filenotfoundexception nuget

Question

I have a .NET Standard 2.0 project which uses EF Core via the Nuget package Microsoft.EntityFrameworkCore. Below is the relevant PropertyGroup from the *.csproj file:

<ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.4" />
  </ItemGroup>

The solution builds, but at runtime, I get a System.IO.FileNotFoundException:

Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.1.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies.

That assembly is not in the build folder (or any subfolders such as the netstandard2.0 subfolder). It is in %userprofile%\.nuget\ ...

I have tried:

  • Cleaning / Rebuilding
  • Clearing the Nuget cache.
  • Adding <RestoreProjectStyle>PackageReference</RestoreProjectStyle> to the *.csproj file.
  • Removing and re-adding Micrososft.EntityFrameworkCore (and Microsoft.EntityFrameworkCore.Design, which is also used)

Is there some other way of forcing the package to be included in the build folder (like Local Copy)?

1
3
11/13/2018 2:36:08 AM

Accepted Answer

Editing the *.csproj files and adding the following to a PropertyGroup seems to have fixed the problem (or at least provided a reasonable workaround):

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
0
11/22/2018 2:40:24 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow