-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In EF7, SqLite unable to load spatialite using the NetTopologySuite Package #29584
Comments
This on windows, so it should be pulled in by nuget? The spatialite binaries appear to be present in the runtimes folder as they were in the old version. |
Further update, This is my project file:-
If I change to net6.0 and 6.0.0 for the packages then it works, with net7.0 I get the error above. |
I faced the same issue and came up with the following work-a-round, which is working for me (.net 7 / EF Core 7 / Windows): In my database context in the OnConfiguring call:
I use a IDbContextFactory to create / load a new database context. I have p/invoke definition inside the class:
In the the CreateDbContext() call I have:
Probably this can be simplified, but I noticed the p/invoke call to spatialite_version triggers the load of the module in mem, and the dynamic load of the mod_spatialite module did the trick (see https://www.gaia-gis.it/fossil/libspatialite/wiki?name=mod_spatialite). EF Core internally use the sqlite function call to load an extension that seem to fail without any (reasonable) reason. btw; same PackageReferences as @woodmeister |
Workaround good for me too. I needed to put the sqlitecommand in a using so it get's disposed, otherwise there are problems with the machinery later on. |
We also encountered this issue with the topology suite and SQLITE in EF Core 7. We altered the above work around to use:
Which I can't take credit for - it's a suggestion by Visual Studio. |
This comment was marked as outdated.
This comment was marked as outdated.
Is there any plans to get this fixed? Thanks :-) |
@hallqvist It is being investigated. |
Sound great, thanks @ajcvickers :-) |
Encountered the same issue when upgrading from EF 6.0.5 to EF 7.0.1 Will have to revert back to EF 6.X for now... Error can be reproduced easily with the following console app program: csproj file
Program.cs
The above code works fine with EFCore 6.X but throws an exception in EFCore 7.X |
This looks like an issue somewhere in SQLitePCLRaw. Filed ericsink/SQLitePCL.raw#532 to follow up. |
🩹 WorkaroundYou can work around this issue by upgrading to the latest (currently pre-release) package of SQLitePCLRaw: <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite" Version="7.0.1" />
+ <PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.4-pre20230105221937" />
</ItemGroup> |
@bricelam I have verified this work around does indeed work via unit tests. Was able to upgrade to the latest version of Entity Framework Core on my project with Sqlite with the spatial extension - thank you... Any idea when this work around will no longer be needed? |
SQLitePCLRaw plans to release sometime this week. After which, we'll update1 our dependency hopefully in time for the Feburay 7.0.x patch. 1 With the caveat that the final decision about whether to patch an issue is made by the .NET Directors, not us. |
Thank you for the good work!
Op ma 9 jan. 2023 19:56 schreef Brice Lambson ***@***.***>:
… SQLitePCLRaw plans to release sometime this week. After which, we'll update
1 our dependency hopefully in time for the Feburay 7.0.x patch.
1 With the caveat that the final decision about whether to patch an issue
is made by the .NET Directors, not us.
—
Reply to this email directly, view it on GitHub
<#29584 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL4NXWMVVK5F4VY246LBWILWRRNOTANCNFSM6AAAAAASCDCG7E>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
If anyone reading this also lives with mild dyslexia: The documentation at https://learn.microsoft.com/en-us/ef/core/providers/sqlite/spatial#installing-spatialite says to install package @ajvickers already said to install that package, but I had found the learn.microsoft.com docs first, couldn't figure out the problem, saw this issue, and couldn't see what was different, because I just didn't see the little Whoever made those packages needs to learn something about one of the four hard computer science problems: naming things. The others being cache invalidation and off-by-one errors. |
@capnmidnight That code listing in the docs is for how to work around an issue with PROJ6 on macOS/Linux where you do need to use |
Hi,
In EF 7 I using the Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite package a simple example does not seem to be able to load the spatialite library
I get "Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 1: ''.'" implying sqlite has returned an error code, but not given any more information about it.
This was all working fine in EF 6
Stacktrace:-
Example code:-
The text was updated successfully, but these errors were encountered: