dotnet / dotnet/EntityFramework.Docs

Sqlite Spatial: dotnet 5.0.11 crashes when loading Spatial Extension

Open
#3,534 4 comments 0 reactions 0 assignees View on GitHub
area-spatial area-sqlite
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

## File a bug

I think I've ran in to something similar as dotnet/efcore#16667 but for version 5.0.11 instead.

According to the [instructions](https://docs.microsoft.com/en-us/ef/core/providers/sqlite/spatial) on the sqlite spatial package I should be using the following imports

```xml




```

I have replaced these with the current versions of the packages

```xml




```

And added the following line to my docker file:

```docker
RUN apt-get install -y sqlite3 libsqlite3-mod-spatialite
```

I get the following error

```
dotnet/efcore#28 93.52 Error Message:
dotnet/efcore#28 93.52 System.TypeInitializationException : The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
dotnet/efcore#28 93.52 ---- System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
dotnet/efcore#28 93.52 -------- System.DllNotFoundException : Unable to load shared library 'sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libsqlite3: cannot open shared object file: No such file or directory
dotnet/efcore#28 93.52 Stack Trace:
dotnet/efcore#28 93.52 at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)
dotnet/efcore#28 93.52 at BokaMera.Api.IntegrationTest.Tests.BokaMeraContext.SeedTests.CanSeedContextAsync() in /app/Tests/BokaMera.Api.IntegrationTest/Tests/BokaMeraContext/SeedTests.cs:line 29
dotnet/efcore#28 93.52 --- End of stack trace from previous location ---
dotnet/efcore#28 93.52 ----- Inner Stack Trace -----
dotnet/efcore#28 93.52 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
dotnet/efcore#28 93.52 at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
dotnet/efcore#28 93.52 at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
dotnet/efcore#28 93.52 at Microsoft.Data.Sqlite.SqliteConnection..cctor()
dotnet/efcore#28 93.52 ----- Inner Stack Trace -----
dotnet/efcore#28 93.52 at SQLitePCL.SQLite3Provider_sqlite3.NativeMethods.sqlite3_libversion_number()
dotnet/efcore#28 93.52 at SQLitePCL.SQLite3Provider_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()
dotnet/efcore#28 93.52 at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)
dotnet/efcore#28 93.52 at SQLitePCL.Batteries_V2.Init()
```

Things work fine when running on Windows. Is there anything I'm missing with the instructions, or any workaround I can do to get up and running?

I tried setting LD_DEBUG=all when building the docker but it just truncates the output since there is way to much.

### Include provider and version information

EF Core version: 5.0.11
Database provider: Microsoft.EntityFrameworkCore.Sqlite.Core
Target framework: .NET 5.0
Operating system: Ubuntu docker image: mcr.microsoft.com/dotnet/sdk:5.0-buster-slim

I understand from reading around that @bricelam have a lot of insight in the matter, is there anything obvious you see? Or anything I can do to provide more information?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.