Skip to content

Document using NetTopologySuite with spatialite on Docker #3443

@jcrawfor74

Description

@jcrawfor74

SQLite Error 1: 'mod_spatialite.so: cannot open shared object

Hi,

I am getting the following error.

  • Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'mod_spatialite.so: cannot open shared object file: No such file or directory'.

I have been researching a solution and read through the various sqlite ef documentation but with no luck fixing the issue.

The scenario;

  • .net core 5.0 webapi.
  • entity framework core sqlite (5.0.10)
  • NetTopologySuite (5.0.10)
  • Docker Image

This code is working on windows.
As a docker image hosted on docker desktop (windows), it is throwing the error above.
On an Ubuntu Linux box (20.04.3) and this also crashes but differently.

The code

  • creates an in memory sqlite database as part of the startup, and
  • then inserts some test data into the database.
  • GET reads the data
  • PUT updates the data

On the docker image it is crashing on the database creation step.
On the Linux box it crashes on the EF data insertion, (if I remove the NetTopologySuite on the EntityFramework OnConfiguringI was able to get it too run successfully).

I don't, particularly care about getting it working on the linux box (just using it for trouble shooting), but I am attempting to host this architecture stack as a docker image on an AWS ECS container, and I need the Spatial Data for my solution.

I have followed the help from here - https://docs.microsoft.com/en-us/ef/core/providers/sqlite/spatial
I have tried various SQLitePCLRaw providers but I am not familiar with how to use these to fix the issue.
Any pointers on what I am doing wrong would be greatly appreciated.

Full code sample here on github.
https://github.com/jcrawfor74/homedev-webapi-sqlite

provider and version information

EF Core version: 5.0.10
Database provider: Microsoft.EntityFrameworkCore.Sqlite.Core
Target framework: (e.g. .NET 5.0)
Operating system: Linux Docker Image
IDE: VS Code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions