Bit.Bsqlite
11.0.0-pre-22
See the version list below for details.
dotnet add package Bit.Bsqlite --version 11.0.0-pre-22
NuGet\Install-Package Bit.Bsqlite -Version 11.0.0-pre-22
<PackageReference Include="Bit.Bsqlite" Version="11.0.0-pre-22" />
<PackageVersion Include="Bit.Bsqlite" Version="11.0.0-pre-22" />
<PackageReference Include="Bit.Bsqlite" />
paket add Bit.Bsqlite --version 11.0.0-pre-22
#r "nuget: Bit.Bsqlite, 11.0.0-pre-22"
#:package Bit.Bsqlite@11.0.0-pre-22
#addin nuget:?package=Bit.Bsqlite&version=11.0.0-pre-22&prerelease
#tool nuget:?package=Bit.Bsqlite&version=11.0.0-pre-22&prerelease
bit Bsqlite
EF Core on SQLite-WASM for Blazor WebAssembly - and on the device's native SQLite for Blazor Hybrid, with the same registration. 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 - the browser assets (SQLite engine builds, worker host, VFSes) served
under _content/Bit.Bsqlite, and the file system backend a Blazor Hybrid app runs on. The native SQLite engine a Blazor Hybrid
app opens its files with is not in it: add SQLitePCLRaw.bundle_e_sqlite3 (or the SQLitePCLRaw bundle the app
already uses) to the Hybrid app's project.
Runtime: .NET 10 and 11, 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) |
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) |
indexeddb |
JSPI where available, Asyncify otherwise | Persistent, the widest browser reach and the fallback behind OPFS. Fixed page size; readers serialize. |
BsqliteCacheStorageProvider (Bit.Bsqlite) |
cache-storage |
JSPI where available, Asyncify otherwise | Persistent: 4096-byte pages in the Cache API, committed through a journal. |
BsqliteInMemoryStorageProvider (Bit.Bsqlite) |
in-memory |
Synchronous | Volatile: gone on reload. Tests, demos, and a declared last resort. |
BsqliteFileSystemStorageProvider (Bit.Bsqlite) |
file-system |
None - the native SQLite the app brings (SQLitePCLRaw.bundle_e_sqlite3, or the bundle it already uses) |
Blazor Hybrid only, registered and selected for it automatically: plain SQLite files in the app's own folder. |
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>();
In a Blazor Hybrid app (MAUI, WPF, Windows Forms) the same registration works unchanged: Bsqlite
adds the file-system backend, ranks it ahead of the browser ones, and keeps the database as a SQLite
file in the app's own folder. ConfigureFileSystemStorage(o => o.RootDirectory = ...) moves it.
A WebAssembly app can instead download Bit.Bsqlite and EF Core only when a page that uses the database
opens: it leaves the registration out of Program.cs, and the pages make it with
provider.GetBitBsqliteServices(AppDatabase.Register) once the assemblies have loaded - see
lazy loading.
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. Blazor Hybrid keeps the
same rule, so one code path serves both. 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
IBsqliteStorageProvider- the same public contract the backends above are built on - and inherit the conformance kit fromBit.Bsqlite.Testing.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 && < 12.0.0)
- SQLitePCLRaw.core (>= 3.0.5 && < 4.0.0)
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 |