Bit.Bsqlite
11.0.0-pre-10
dotnet add package Bit.Bsqlite --version 11.0.0-pre-10
NuGet\Install-Package Bit.Bsqlite -Version 11.0.0-pre-10
<PackageReference Include="Bit.Bsqlite" Version="11.0.0-pre-10" />
<PackageVersion Include="Bit.Bsqlite" Version="11.0.0-pre-10" />
<PackageReference Include="Bit.Bsqlite" />
paket add Bit.Bsqlite --version 11.0.0-pre-10
#r "nuget: Bit.Bsqlite, 11.0.0-pre-10"
#:package Bit.Bsqlite@11.0.0-pre-10
#addin nuget:?package=Bit.Bsqlite&version=11.0.0-pre-10&prerelease
#tool nuget:?package=Bit.Bsqlite&version=11.0.0-pre-10&prerelease
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 except a persistent backend: the EF Core integration, the
ADO.NET surface with live queries, the worker transport, the storage provider contract, a volatile
in-memory backend, and the browser assets (SQLite engine builds, worker host, JavaScript API) 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
Add a persistent backend — without one you get the in-memory provider, which does not survive a reload:
| Package | Notes |
|---|---|
Bit.Bsqlite.Storage.Opfs |
Sync engine (smallest download), multi-connection, worker-only |
Bit.Bsqlite.Storage.IndexedDb |
Widest browser reach, runs anywhere, JSPI/Asyncify |
Bit.Bsqlite.Storage.CacheStorage |
Imports a database left behind by Bit.Besql |
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.
Links
- Documentation and source, and the demo website at bsqlite.bitplatform.dev
- Issues
- Writing your own storage backend: implement
IBsqliteStorageProviderand inherit the conformance kit fromBit.Bsqlite.Testing.
| Product | Versions 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. net11.0 is compatible. |
-
net10.0
- Microsoft.EntityFrameworkCore.Sqlite.Core (>= 10.0.0 && < 11.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0 && < 11.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0 && < 11.0.0)
- Microsoft.JSInterop (>= 10.0.0 && < 11.0.0)
- SQLitePCLRaw.core (>= 2.1.13 && < 3.0.0)
-
net11.0
- Microsoft.EntityFrameworkCore.Sqlite.Core (>= 11.0.0-rc.1.26425.128 && < 12.0.0)
- Microsoft.JSInterop (>= 11.0.0-rc.1.26425.128 && < 12.0.0)
- SQLitePCLRaw.core (>= 3.0.5 && < 4.0.0)
-
net8.0
- Microsoft.EntityFrameworkCore.Sqlite.Core (>= 8.0.11 && < 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0 && < 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0 && < 9.0.0)
- Microsoft.JSInterop (>= 8.0.0 && < 9.0.0)
- SQLitePCLRaw.core (>= 2.1.13 && < 3.0.0)
-
net9.0
- Microsoft.EntityFrameworkCore.Sqlite.Core (>= 9.0.0 && < 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0 && < 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0 && < 10.0.0)
- Microsoft.JSInterop (>= 9.0.0 && < 10.0.0)
- SQLitePCLRaw.core (>= 2.1.13 && < 3.0.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Bit.Bsqlite:
| Package | Downloads |
|---|---|
|
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. |
|
|
Bit.Bsqlite.Testing
Test support for bit Bsqlite: an in-process IBsqliteTransport backed by Microsoft.Data.Sqlite, 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. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0-pre-10 | 56 | 10/18/2026 |