ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

Ef 7 Sqlite with topology on ubuntu crashes #505

Closed szekelymatyas closed 1 year ago

szekelymatyas commented 1 year ago

So im using the latest preview of .net7 and ef7 too. On windows its working fine.

Here is my project file's relevant packages:

<ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite" Version="7.0.0-preview.7.22376.2" />
</ItemGroup>

<ItemGroup Label="Windows only includes" Condition=" '$(OS)' == 'Windows_NT' ">
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0-preview.7.22376.2" />
</ItemGroup>

<ItemGroup Label="Linux only includes" Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' ">
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.0-preview.7.22376.2" />
    <PackageReference Include="SQLitePCLRaw.bundle_sqlite3" Version="2.1.0" />
</ItemGroup>

Here is the docker file parts thats install the dependencies:

RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y sqlite3 libsqlite3-dev libsqlite3-mod-spatialite
RUN apt -y update
RUN mkdir /db
RUN /usr/bin/sqlite3 /db/test.db
RUN sqlite3 --version

The program crashes on save changes. Here is the exceptions relevant part i guess:

Microsoft.EntityFrameworkCore.DbUpdateException : An error occurred while saving the entity changes. See the inner exception for details.
---- Microsoft.Data.Sqlite.SqliteException : SQLite Error 1: 'near "RETURNING": syntax error'.
  Stack Trace:
     at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9.UpdateAsync(TUser user, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Identity.UserManager`1.UpdateUserAsync(TUser user)
   at Microsoft.AspNetCore.Identity.UserManager`1.AddToRoleAsync(TUser user, String role)

The project is working on windows and also working on ubuntu with PostgresSQL provider. Can someone help me solve this one? I'm not exactly sure whats going on in the background.

szekelymatyas commented 1 year ago

Feeln stupid right now. Ubuntu's sqlite version is 3.34. RETURNING is supported from 3.36

bricelam commented 1 year ago

Thanks for calling attention to this. We'll be sure to add it to the list of breaking changes in EF7.