Join our Discord server for community support and discussions Icon description

WebAssembly Support for SQLite and Erik Sink’s SQLitePCL.raw has been present in Uno Platform for quite some time now, when running under the mono runtime but .NET 5+ support was missing.

We’re pleased to announce that support has now been added in our SQLite provider for WebAssembly starting from 3.1.1, allowing to build with the latest and greatest features available, alongside with Entity Framework Core 6 previews and the Frank Krueger‘s awesome sqlite-net-pcl library.

We’ve updated our online sample repository for you to try SQLite and EntityFramework Core directly in your browser:

https://sqliteefcore-wasm.platform.uno

 

Getting started using SQLite in your browser

You can find an up-to-date documentation for this walkthrough here, the full example for this tutorial here, and Entity Framework Core sample here.

First, you’ll need to setup your environment using our getting started steps.

Once you’re done, you can create a new application using our visual studio extension or dotnet new templates.

You’ll then need to add new dependencies in your application as follows:

<PackageReference Include="sqlite-net-pcl" Version="1.7.335" />
<PackageReference Include="Uno.SQLitePCLRaw.provider.wasm" Version="3.1.1" />
<!-- Required when using sqlite-net-pcl which otherwise overrides the WebAssembly compatible version of the SQLitePCL.raw provider. -->
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.0.5-pre20210521085756" IncludeAssets="none" />

 

Once done, in your application, you can start using SQLite as you would in the other platforms:

// Get an absolute path to the database file
var databasePath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "MyData.db");
var exists = File.Exists(databasePath);
var db = new SQLiteConnection(databasePath);
if (!exists)
{
    db.CreateTable<Stock>();
    db.CreateTable<Valuation>();
}

New to Uno Platform?

The above update is meaningful only to those of you who are already using Uno Platform. If you are not, you can also familiarize yourself with Uno Platform through our 3-min getting started tutorial.

Uno Platform 5.2 LIVE Webinar – Today at 3 PM EST – Watch