8

I am using Microsoft.EntityFrameworkCore.Sqlite version 2.2.4 Microsoft.EntityFrameworkCore version 2.2.4 nuget packages on my .net core class library.

When adding my class library to Console application I am getting the following exception: FileNotFoundException: Could not load file or assembly 'SQLitePCLRaw.core, Version=1.1.12.351, Culture=neutral, PublicKeyToken=1488e028ca7ab535'. The system cannot find the file specified.

My code is running on windows but will also run on Linux.

Is there any solution?

I saw a recommendation for adding Microsoft.EntityFrameworkCore.Sqlite nuget to my console application. but I prefer avoiding this solution.

user1551454
  • 151
  • 2
  • 7
  • 3
    Try adding a reference to Microsoft.Data.Sqlite package, and calling `Batteries.Init();` at the start of your program. – Lasse V. Karlsen May 16 '19 at 14:15
  • After adding Microsoft.Data.Sqlite and calling Batteries.Init(), I am getting new error: Could not load file or assembly 'SQLitePCLRaw.batteries_green, Version=1.1.12.351, Culture=neutral, PublicKeyToken=a84b7dcfb1391f7f'. The system cannot find the file specified.' – user1551454 May 16 '19 at 19:44
  • Call Batteries.Init() solved my problem too. Took one day to find this post! But you need this package. SQLitePCLRaw.bundle_green – Egbert Nierop Nov 24 '19 at 18:22

3 Answers3

3

i just faced same problem and doing these steps solve it

  1. remove obj and bin folder
  2. run dotnet restore --force
sajjad kalantari
  • 723
  • 8
  • 23
2

I had to Downgrade to a lower version.

<PackageReference Include="sqlite-net-pcl" Version="1.6.292" />
<!--<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />-->
Joseph Wambura
  • 2,732
  • 2
  • 21
  • 24
  • This solution worked for me (but from VS22 NuGet Packages interface). I was following some tutorial instructions. I guess that the newer dependency of `sqlite-net-pcl` does something unexpected from the time that tutorial was made. – carloswm85 Mar 29 '23 at 20:34
0

Just had this issue - something had set AutoGenerateBindingRedirects to false in my .csproj file. Reverting it back to true fixed it.

Sean
  • 2,033
  • 2
  • 23
  • 28