Skip to content

Latest commit

 

History

History
66 lines (41 loc) · 3.62 KB

README.md

File metadata and controls

66 lines (41 loc) · 3.62 KB

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>