Error when migrating EF Core data type Point from NetTopologySuite for SqLite

0

Using EntityFrameworkCore 3.1.5, I installed NetTopologySuite 3.1.5 for Spatial Data types. I also installed the Spatialite extension for MacOS, which seemed to install with no errors and I checked the version which showed 4.3. Added a point property to my entity

public Point Location { get; set; } // from NetTopologySuite.Geometries;

Created a migration file

migrationBuilder.AlterDatabase()
  .Annotation("Sqlite:InitSpatialMetaData", true);

migrationBuilder.AddColumn<Point>(
  name: "Location",
  table: "MyTable",
  nullable: true);

And then migrated automatically, using

await context.Database.MigrateAsync(); // in Program.cs -> automatically migrates when >dotnet run is called

I get the error

fail: Microsoft.EntityFrameworkCore.Database.Connection[20004] An error occurred using the connection to database 'main' on server 'mydatabase.db'. fail: API.Program[0] An error occured during migration Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'dlopen(mod_spatialite.dylib, 10): image not found'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery() at Microsoft.Data.Sqlite.SqliteConnectionExtensions.ExecuteNonQuery(SqliteConnection connection, String commandText, SqliteParameter[] parameters) at Microsoft.Data.Sqlite.SqliteConnection.LoadExtensionCore(String file, String proc) at Microsoft.Data.Sqlite.SqliteConnection.Open() at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalarAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.ExistsAsync(CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.MigrateAsync(String targetMigration, CancellationToken cancellationToken) at API.Program.Main(String[] args) in /Users/myname/myproject/API/Program.cs:line 25

FYI - I have 3 .Net Core project (API, Core, Infrastructure) I installed the NetTopology suite into Core (contains entities) and Infrastructure (contains EF Core and all database repos). I DID NOT install it in my API, where I run the migrations from, does this make any difference? Or does NetTopologySuite not run on Sqlite?

c#
sqlite
.net-core
entity-framework-core
nettopologysuite
asked on Stack Overflow Jul 9, 2020 by user1186050 • edited Jul 9, 2020 by user1186050

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0