#Using SQLite with Entity Framework on Android

1 messages · Page 1 of 1 (latest)

summer patio
#

Has anyone tried using SQLite with Entity Framework (.NET) on Android?
It works perfectly fine on Windows, but doesn't work on Android exports

I'm getting the System.DLLNotFoundException: e_sqlite3 and seems like I've tried everything I was able to find to fix it
Most of the tries were around sqlite-net-pcl and several SQLitePCLRaw.* NuGet packages of different versions

summer patio
#

<@&1349109171240439858> Sorry for pinging, but this question is quite specific and I really need it for project migration from Xamarin to Godot. Maybe someone knows if it is even possible to resolve the issue above? As a backup plan, I'll reinvent quite a lot of wheels on order to implement some of the EF functionality, but there is still a hope that it will not be needed...

idle pelican
#

Entity framework is like a lightweight version of the .NET used by Godot. There's likely to be a few things missing, so absent DLL files aren't a surprise.

summer patio
#

So you mean there is no workaround for this situation and I need to reinvent all the wheels EF already has? I'm trying to understand if it is a Godot limitation, limitation of the EF or maybe even .NET running on Android.

I tried to unzip the resulting .apk file and it has the library file (libe_sqlite3.so) it is complaining about at runtime. So it is hard to tell where the problem is...

sand tartan
#

Is EF somekind of extension?

summer patio
#

EF is EntityFramework which is ORM (Object-relational mapping). Basically it helps to map .NET classes to entities in any supported database (SQLite in my case) and it provides unified methods for the database data manipulation through abstractions (like var admins = _dbContext.Users.Where(u => u.Role == UserRoles.Admin).ToList(). It is used primarily to add an extra layer of abstraction to for database access (no need to write SQL queries, no need to support them for various database servers, etc.)

cerulean bone
#

Seems like the issue is missing libraries. How are you shipping the EF libraries for android?

#

Ah, I just read further on

#

A couple different threads online seem to suggest that a clean rebuild of the dotnet solution could fix the issue

#

I'm not that familiar with c# build and packaging process, or in fact with EF, but if the issue persists, maybe we can figure out if something's wrong with how Godot packages the build. It would help to see your export configuration in Godot, the steps you perform to export and deploy to your android device, and the contents of the resulting build directory/package for both android and windows.

#

also, you might be able to spot any Godot-side issues easier if you perform an export from command line:

godot4 -v --headless --export-release Export-preset-name path/to/output/file

(same with --export-debug)

summer patio
#

Thanks for these tips. I already tried to run a clean rebuild and a couple of other suggestions from this GitHub issue, but it did not help. I'll try to make a minimal project and build it from command line tomorrow and let you know about the result. The weirdest part here is that renaming .apk to .zip and checking its contents shows the library I need, but for some reason it can't be detected at runtime...

I think, it could be not Godot-only problem because I had a similar issue with Xamarin and was not able to use Entity Framework as well.

summer patio
#

@cerulean bone I've tried to perform an .apk export from the command line, it run without errors (except the missing icon, I removed it), but this System.DLLNotFoundException: e_sqlite3 exception is still here. I've attached the command line export log (it is clear, but just in case), almost minimal possible project to reproduce the issue and the resulting .apk file (signed in debug mode). Not really sure where to ask for a help since don't know yet if it is a Godot, Entity Framework, SQLite or Android issue...

#

After starting this test application you'll see the TextEdit control and 3 buttons. There is a description what each of the button does, but in general after pressing the TEST button it should give you a number (which will be stored in database file and incremented after each button click) or an exception. If it gives an exception related to file system access - treat it is a success (I was not able to check which permissions I need to add), but anything SQLite related means it doesn't work on Android...

summer patio
gentle glacier
#

commenting here so i get answers and updates bc i want to know

#

hahaaha

summer patio
#

I think, it needs to be escalated on GitHub so someone more experienced in this topic can confirm that it is a limitation of EF (I don't think so because I used it with Xamarin and MAUI before) or something that needs to be fixed in Godot's build system

sinful ferry
summer patio
#

No, I use Entity Framework to work with SQLite and any other databases such as SQL Server and PostgreSQL
I wanted to use an existing database context, its entities and related services I had before switching to Godot
It is C#, not GDScript so this plugin is not relevant for my use case

But it seems to be a nice plugin for GDScript-only prototypes 🙂

cerulean bone
summer patio
#

Exception's name could be a bit confusing: DLL in its name stands for Dynamically Linked Library and .dll and .so are some of the common file name extensions for those libraries

So it expects a dynamic library and its file extension is tied to the runtime platform being used, but for some reason it can't be found on Android while in fact it is an .apk file

I suppose, the file itself may have a different structure so it can't be parsed properly by the runtime if it is not Xamarin or MAUI, but I'm not sure