Bit.Bsqlite 10.7.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Bit.Bsqlite --version 10.7.0
                    
NuGet\Install-Package Bit.Bsqlite -Version 10.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bit.Bsqlite" Version="10.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bit.Bsqlite" Version="10.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Bit.Bsqlite" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bit.Bsqlite --version 10.7.0
                    
#r "nuget: Bit.Bsqlite, 10.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bit.Bsqlite@10.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bit.Bsqlite&version=10.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Bit.Bsqlite&version=10.7.0
                    
Install as a Cake Tool

bit Bsqlite

EF Core on SQLite-WASM for Blazor WebAssembly. The same entities and the same migrations on the client as on the server.

This package is everything you need: the EF Core integration, the ADO.NET surface with live queries, the worker transport, the storage provider contract, the storage backends - OPFS, IndexedDB, Cache Storage and in-memory - and the browser assets (SQLite engine builds, worker host, VFSes) served under _content/Bit.Bsqlite.

Runtime: .NET 8, 9 and 10, each with its EF Core. License: MIT (bundles wa-sqlite, also MIT).

Install

dotnet add package Bit.Bsqlite

Storage backends

Register the ones you want with AddStorageProvider<T>(). Registering one costs the browser nothing until it is selected: the worker imports only the selected backend's VFS, and the one engine build it needs.

Provider (namespace) Name Engine build Notes
BsqliteOpfsStorageProvider (Bit.Bsqlite.Storage.Opfs) opfs Synchronous — the smallest download Persistent, real files in the origin private file system, several connections, worker-only, no COOP/COEP headers. Pick it when you can.
BsqliteIndexedDbStorageProvider (Bit.Bsqlite.Storage.IndexedDb) indexeddb JSPI where available, Asyncify otherwise Persistent, the widest browser reach and the fallback behind OPFS. Fixed page size; readers serialize.
BsqliteCacheStorageProvider (Bit.Bsqlite.Storage.CacheStorage) cache-storage JSPI where available, Asyncify otherwise Persistent. Imports a database left behind by Bit.Besql losslessly on first open - the migration path off Besql.
BsqliteInMemoryStorageProvider (Bit.Bsqlite.Storage.InMemory) in-memory Synchronous Volatile: gone on reload. Tests, demos, and a declared last resort.

The three persistent providers take an optional IJSRuntime and report themselves unavailable without one, so selection also runs - and explains itself - in desktop tests. The capabilities each one declares, and what the core does with them, are in the storage guide.

Register

builder.Services.AddBitBsqliteServices(sqlite => sqlite
    .AddStorageProvider<BsqliteOpfsStorageProvider>()
    .AddStorageProvider<BsqliteIndexedDbStorageProvider>()
    .AddStorageProvider<BsqliteInMemoryStorageProvider>()
    .UseStorage(s => s
        .Prefer(BsqliteOpfsStorageProvider.ProviderName)
        .Fallback(BsqliteIndexedDbStorageProvider.ProviderName)
        .Fallback(BsqliteInMemoryStorageProvider.ProviderName)
        .AllowNonPersistentFallback())
    .AddDatabase("app.db"));

builder.Services.AddBitBsqliteDbContext<AppDbContext>();

Use

@inject IBsqliteDbContextFactory<AppDbContext> Contexts

await using var db = await Contexts.CreateDbContextAsync();   // migrates once per session
var open = await db.Orders.Where(o => o.Open).ToListAsync();

Without dependency injection the same pieces compose by hand:

var session = await factory.OpenAsync("app.db");   // a BsqliteSessionFactory
options.UseBitBsqlite(session.Connection);

Selection is sticky: existing data outranks preference, so a database already written on one backend is reopened there rather than silently starting empty somewhere else. BsqliteStorageMigrationMode.KeepExisting is the default; AutomaticOnOpen copies the image, verifies the SQLite header, then flips the binding.

Live queries

Table-level, and they fire across tabs. A committed write re-runs any live query that reads that table. The worker learns what changed from SQLite's own update hook - cascades and triggers included - and reports it once the transaction commits, so a rolled-back write is never shown and a multi-statement SaveChangesAsync re-runs a query once, not per statement.

await using var live = ctx.Orders.Where(o => o.Open).AsLiveQuery();
live.Changed += (_, rows) => InvokeAsync(StateHasChanged);

Async only

The browser cannot block on storage, so the synchronous ADO.NET surface throws BsqliteSynchronousApiNotSupportedException rather than deadlocking or lying. Use the Async overloads throughout — ToListAsync, SaveChangesAsync, MigrateAsync.

Hosting under a sub-path

Every asset is reached relative to the document, the way Blazor's own are, so an application published under <base href="/app/"> needs no configuration: the host resolves each provider's VFS module - and each extension module - against the document base before the worker imports it.

Caching the browser assets

The host module is imported with a ?v=<assembly version> query and passes it on to the worker and the modules it loads, so an upgrade cannot pair new .NET with JavaScript the browser cached from an older version. The engine files under _content/Bit.Bsqlite/engine carry no query - they change only when the pinned wa-sqlite version does - so if your server sends long max-age headers for static content, exclude _content/Bit.Bsqlite/ or serve it with Cache-Control: no-cache so the browser revalidates.

  • Documentation and source, and the demo website at bsqlite.bitplatform.dev
  • Issues
  • Writing your own storage backend: implement IBsqliteStorageProvider - the same public contract the backends above are built on - and inherit the conformance kit from Bit.Bsqlite.Testing.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Bit.Bsqlite:

Package Downloads
Bit.Bsqlite.Testing

Test support for bit Bsqlite: an in-process IBsqliteTransport backed by Microsoft.Data.Sqlite - the native transport Blazor Hybrid apps run on, recording what it executes - so the stack can be unit-tested on desktop .NET without a browser, and the MSTest conformance kit every storage provider must pass - inherit its test classes in your provider's test project and hand them your provider.

Bit.Bsqlite.Storage.CacheStorage

Cache Storage for bit Bsqlite: block-based and journal-committed, and the migration path off Bit.Besql - a database Bit.Besql left in Cache Storage is imported losslessly on first open.

Bit.Bsqlite.Storage.Opfs

OPFS storage for bit Bsqlite, using wa-sqlite's OPFSCoopSyncVFS: persistent, multi-connection, worker-only and without COOP/COEP headers.

Bit.Bsqlite.Storage.IndexedDb

IndexedDB storage for bit Bsqlite, using wa-sqlite's IDBBatchAtomicVFS: persistent, async-capable (JSPI or Asyncify), and available where OPFS is not.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.0-pre-23 93 11/19/2026
11.0.0-pre-22 67 11/18/2026
11.0.0-pre-21 134 11/17/2026
11.0.0-pre-20 420 11/15/2026
11.0.0-pre-19 317 11/13/2026
11.0.0-pre-18 283 11/11/2026
11.0.0-pre-17 615 11/4/2026
11.0.0-pre-16 285 11/2/2026
11.0.0-pre-15 307 10/27/2026
11.0.0-pre-14 73 10/26/2026
11.0.0-pre-13 74 10/26/2026
11.0.0-pre-12 65 10/26/2026
11.0.0-pre-11 74 10/25/2026
11.0.0-pre-10 102 10/18/2026
10.7.0 1,397 10/25/2026
10.7.0-pre-04 113 10/25/2026
10.7.0-pre-03 113 10/22/2026
10.7.0-pre-02 118 10/22/2026