An SQLiteRaw WebAssembly provider for SQLitePCLRaw.core
Перейти к файлу
Jérôme Laban 05def09d7c
chore: adjust versions
2024-06-19 09:27:45 -04:00
.github/workflows ci: Restore container for ninja dependency 2024-01-09 10:48:23 -05:00
build chore: Add package signing 2024-01-09 10:06:22 -05:00
src chore: adjust versions 2024-06-19 09:27:45 -04:00
.gitattributes Initial commit 2018-09-26 09:13:10 -04:00
.gitignore chore: Add package signing 2024-01-09 10:06:22 -05:00
.vsts-ci.yml ci: Restore container for ninja dependency 2024-01-09 10:48:23 -05:00
LICENSE.md Initial commit 2018-09-26 09:13:10 -04:00
README.md chore: adjust versions 2024-06-19 09:27:45 -04:00
gitversion-step.yml ci: update gitversion 2021-08-03 23:08:02 -04:00
gitversion.yml ci: Adjust for versioning 2021-08-05 11:08:07 -04:00

README.md

Uno Platform based SQLitePCLRaw provider for WebAssembly

This repository is the home for the SQLitePCLRaw provider for WebAssembly, providing SQLite support for EntityFramework Core, SQLite-net, or any SQLitePCLRaw-based library.

The package is using Uno.sqlite-wasm, a WebAssembly built binary for the SQLite database engine.

You can see it in action here: http://sqliteefcore-wasm.platform.uno/

The Nuget package is available here: Uno.SQLitePCLRaw.provider.wasm

Usage

SQLitePCL.Batteries.Init();

Usage With sqlite-net-pcl

When using the SQLitePCL.Raw with sqlite-net-pcl, you'll need additional configuration:

<PackageReference Include="sqlite-net-pcl" Version="1.7.335" />
<PackageReference Include="Uno.SQLitePCLRaw.provider.wasm" Version="3.0.15" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.8" IncludeAssets="none" />

The SQLitePCLRaw.bundle_green must be exlcuded explicitly as it does not work properly with WebAssembly, but cannot be removed as it is a transitive dependency of sqlite-net-pcl. Adding this last reference ensure that the proper native library is loaded.

Architecture

This package is providing the SQLite implementation used by many database abstractions, such as SQLite-net or EntityFramework Core.

The SQLite implementation is provided under the covers as a statically linkable bitcode file, and requires the use of the Uno.Wasm.Boostrap.

EFCoreSample

This sample demonstates the use of the SQLitePCLRaw provider for WebAssembly, along with EntityFramework Core and Roslyn using Uno Platform.

The application is built with all the EntityFramework Core binaries, allowing for custom code to be compiled and run locally in the browser, to test EF Core database scenarios dynamically.

Special considerations for Windows build servers when using Uno.Bootstrapper 2.x

If you're building a WebAssembly application with the Uno.SQLitePCLRaw.provider.wasm package on a Windows CI Server, you may get into an error like this one:

Error : System.InvalidOperationException: WSL is required for this build but could not be found (Searched for [C:\windows\sysnative\bash.exe]).

If your CI server does not have WSL enabled (e.g. Azure Devops Hosted Agents), you'll need to disable the static linking of the SQLite native library. It will generate an invalid package, but the build will finish properly.

Note that this restriction is temporary until msbuild supports solution filters (most likely VS 16.7+), where removing some projects from a solution will be lots easier.

Here's how to the static linking of the SQLite native library. In your XX.Wasm.csproj file, add the following:

<PropertyGroup>
	<CanUseAOT Condition="$([MSBuild]::IsOsPlatform('Linux')) or ( $([MSBuild]::IsOsPlatform('Windows')) and '$(BUILD_REPOSITORY_PROVIDER)'=='' )">true</CanUseAOT>
</PropertyGroup>

<ItemGroup Condition="'$(CanUseAOT)'==''">
	<PackageReference Include="Uno.sqlite-wasm" Version="1.1.0-dev.16828" IncludeAssets="none" />
</ItemGroup>