I am creating a spatial database with EntityFrameworkCore.Sqlite.NetTopologySuite to store a point for now but will eventually be for lines etc. I have used the Spatial Data documentation as reference https://learn.microsoft.com/en-us/ef/core/modeling/spatial#sqlite. The data needs to be saved into a Spatialite database.
Having been through the documentation I have reflected the code as it is stated including "UseNetTopology" in the options builder (below) and have created a Point in the class.
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Filename=TestDb.db", x => x.UseNetTopologySuite());
}
When I attempt to update the database with update-database
I receive the error:
SQLite Error 1: 'The specified module could not be found.'.
I have attempted to find the issue by creating a blank project and working from the ground up but the result comes to the same error.
Here is the whole log:
'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Infrastructure.SpatialiteLoader.Load(DbConnection connection)
at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.LoadSpatialite()
at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.Open(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
SQLite Error 1: 'The specified module could not be found.
'.
I cannot find any other post with the same issue.
EDIT 19/8/19: I have just created a new blank project to test without entity framework by installing from the Spatialite website and using SQLite to connect to a spatial database. I received the same error doing it the manual way so perhaps this is an issue with Spatialite?
@Jarb
I solved (temporarily) the issue by copying manually the content of mod_spatialite\4.3.0.1\runtimes\win-x64\native
into the project's bin folder, in my case bin\Debug\netcoreapp2.2\win10-x64
You can follow the thread on GitHub here.
Apparently there is a known issue related to this bug here.