efcore: Unable to load DLL 'e_sqlite3' on EF Core 2.0
I’m testing my code using sqlite in memory database and I get this error when trying to run a test.
System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Further technical details
EF Core version: 2.0.0 Database Provider: Microsoft.EntityFrameworkCore.Sqlite Operating system: Visual Studio 2017
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 35 (13 by maintainers)
Is everyone here using a separate class library for their DbContext? If so, the solution to the original issue is to add a reference to
SQLitePCLRaw.bundle_greento the consuming app/test projects. This is just a known/by-design limitation of how NuGet handles transitive references.@bricelam, @ajcvickers I am still facing this issue even after trying all the answers in this thread. Does this issue still persist in later builds ? I am also using Sqlite db for unit testing with specflow.
Technical Details: Microsoft.EntityFrameworkCore 2.2.4 Microsoft.Data.Sqlite.Core 2.2.4
Solution (at least for raspberry Pi) is following:
This is still an issue.
@bricelam After follow up with https://github.com/ericsink/SQLitePCL.raw/issues/175 the solution is to use
dotnet publish -r win10-armThe build instructions on https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md are missleading.
@bricelam “Is everyone here using a separate class library for their DbContext? If so, the solution to the original issue is to add a reference to SQLitePCLRaw.bundle_green to the consuming app/test projects. This is just a known/by-design limitation of how NuGet handles transitive references.”
Yes, I am trying to do just that… is there any way of bypassing this limitation? I want to deliver the customer just one DLL containing the database layer… don’t want him to have to download extra references.
Yeah, I’m not sure why NuGet doesn’t just treat
win-x*andwin7-x*as aliases during publish…(and
win-armandwin8-arm)Ah, you need to use
win7-x86at least. SQLitePCL.raw doesn’t include a dll forwin-x86.Still having this error in Windows 10, in spite adding
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.0" />as suggested. Weird thing, I had no such error in macOS (probably due to sqlite being part of the system)@bdominguez This looks like an issue with transitive packages in project references in NuGet. Adding the following to
Test.csprojmakes it work.Can you file a new issue on NuGet/Home?
@bdominguez What framework and runtime are you using?
@glegleme According to ericsink/SQLitePCL.raw#161 this should work. You could also try just using the version that ships with Windows 10: