Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

databaseanswers.net Latest Questions

  • 0
Clara
Beginner

Spatial Data in the SQLite EF Core Provider Issue in Ubuntu 22.04

We are using Entity Framework Core 6 and SQLlite with Spatial data in our tests (xunit). in our .csproj we have

<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite" Version="6.0.2" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.0.4" />

here is how we setup SQLite:

var builder = new DbContextOptionsBuilder<DataContext>();
builder.UseSqlite("Data Source=:memory:", x => x.UseNetTopologySuite());
builder.UseLazyLoadingProxies();

and on Ubuntu we installed this package too

apt-get install libsqlite3-mod-spatialite

All tests passes fine on Windows and on Ubuntu 18.04. However, when we upgraded to 22.04, this issue started (on Windows it works):

Failed

App.Tests.Unit.Tests.Services.Maintenance.OurTestAsync [1 ms]
Error Message:
      Microsoft.Data.Sqlite.SqliteException : SQLite Error 21: 'bad parameter or other API misuse'.
Stack Trace:

  at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
  at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
  at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
  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.ExecuteScalar()
  at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalar(RelationalCommandParameterObject parameterObject)
  at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteDatabaseCreator.HasTables()
  at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreated()
  at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated()
  at App.Tests.Unit.TestBase.GetDataContext() in /home/user/app/App.Tests.Unit/TestBase.cs:line 28
  at App.Tests.Unit.Tests.Services.Maitenance.OurTestAsync.ctor() in /home/user/app/App.Tests.Unit/Tests/Services/Maintenance/OurTestAsync.cs:line 23t
  at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

We tried to use Microsoft.EntityFrameworkCore.Sqlite.Core also, but still the issue is the same.

Related Questions

Leave an answer

You must login to add an answer.