ManuHub.IndexedDB 1.2.0

Prefix Reserved
dotnet add package ManuHub.IndexedDB --version 1.2.0
                    
NuGet\Install-Package ManuHub.IndexedDB -Version 1.2.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="ManuHub.IndexedDB" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ManuHub.IndexedDB" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="ManuHub.IndexedDB" />
                    
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 ManuHub.IndexedDB --version 1.2.0
                    
#r "nuget: ManuHub.IndexedDB, 1.2.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 ManuHub.IndexedDB@1.2.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=ManuHub.IndexedDB&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=ManuHub.IndexedDB&version=1.2.0
                    
Install as a Cake Tool

Static Badge NuGet Version NuGet Downloads

πŸ“¦ ManuHub.IndexedDB

v1.2
A lightweight, production-ready IndexedDB wrapper for Blazor WebAssembly with EF-Core-inspired API.


πŸš€ Overview

ManuHub.IndexedDB v1.2 is a robust, multi-entity IndexedDB solution for Blazor WebAssembly. It provides a clean, familiar .NET API while handling the complexities of browser storage.


♻️ Changelog v1.2

Major Improvements

  • Full Multi-Entity Support
  • Robust Migration System with version management
  • Stable Data Persistence
  • Smart Entity Normalization β€” Works with Guid, int, string keys
  • Improved Version Conflict Handling
  • Better Error Messages & Debugging
  • Enhanced Service Registration with options delegate
  • Stable CRUD + Batch Operations

✨ Features

βœ” Full CRUD + Batch operations
βœ” Multi-entity support (multiple stores)
βœ” EF Core-style DbContext pattern
βœ” Robust migration & versioning system
βœ” Guid, int, string key support
βœ” Smart automatic Id handling
βœ” Safe transaction management
βœ” Production-ready stability
βœ” Lightweight & dependency-free


πŸ“¦ Installation

dotnet add package ManuHub.IndexedDB

βš™οΈ Setup

1. Register in Program.cs

builder.Services.AddIndexedDb<AppDbContext>(options =>
{
    options.DatabaseName = "MyAppDb";
    options.Version = 5;                    // Increase when schema changes

    // Migrations (recommended)
    options.Migrations.Add(1, builder =>
    {
        builder.CreateStore<TodoItem>();
        builder.CreateStore<User>();
    });

    // Add more migrations as needed
});

2. Create DbContext

public class AppDbContext : IndexedDbContext
{
    public AppDbContext(IndexedDbOptions options) : base(options) { }

    protected override IEnumerable<Type> GetEntityTypes()
    {
        return [typeof(TodoItem), typeof(User)];
    }

    public IndexedSet<TodoItem> Todos => Set<TodoItem>("TodoItems");
    public IndexedSet<User> Users => Set<User>("Users");
}

3. Define Entities

[IndexedStore("TodoItems")]
public class TodoItem
{
    [IndexedKey]
    public Guid Id { get; set; } = Guid.NewGuid();

    public string Title { get; set; } = string.Empty;
    public bool IsDone { get; set; } = false;
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}

πŸ§ͺ Usage

Basic Operations

// Add
await db.Todos.AddAsync(new TodoItem { Title = "Learn ManuHub.IndexedDB" });

// Get All
var allTodos = await db.Todos.GetAllAsync();

// Query
var completed = await db.Todos.Query()
    .WhereEquals("IsDone", true)
    .ToListAsync();

// Update & Delete
await db.Todos.UpdateAsync(todo);
await db.Todos.DeleteAsync(todo.Id);

Batch Operations

await db.Todos.AddRangeAsync(items);
await db.Todos.UpdateRangeAsync(updatedItems);
await db.Todos.DeleteRangeAsync(idsToDelete);

πŸ”„ Migrations (v1.2 Feature)

Basic Migration Example

builder.Services.AddIndexedDb<AppDbContext>(options =>
{
    options.DatabaseName = "MyAppDb";
    options.Version = 3;   // Current version

    options.Migrations.Add(1, builder =>
    {
        builder.CreateStore<TodoItem>();
        builder.CreateStore<User>();
    });

    options.Migrations.Add(2, builder =>
    {
        builder.CreateStore<Project>();
    });

    options.Migrations.Add(3, builder =>
    {
        builder.CreateStore<TodoItem>(); // Re-apply if needed
        // Optional: Data transformation
        // builder.TransformData<TodoItem>(todo => { ... });
    });
});

Advanced Migration with Data Transformation

options.Migrations.Add(4, builder =>
{
    builder.CreateStore<Order>();

    // Transform existing data during migration
    builder.TransformData<TodoItem>(todo =>
    {
        todo.UpdatedAt = DateTime.UtcNow;
        todo.Version = 2;
        return todo;
    });
});

πŸ›  Architecture

Blazor App
   ↓
IndexedDbContext
   ↓
IndexedSet<T> / IndexedQuery<T>
   ↓
Smart JS Interop Layer (Multi-entity safe)
   ↓
IndexedDB Browser API

βš™οΈ Key Improvements in v1.2

  • Removed hardcoded normalizeEntity (Todo-only)
  • Smart generic entity normalization
  • Reliable database versioning (no more data loss on refresh)
  • Better fallback for Id / Guid keys
  • Stable migration system
  • Improved error handling & logging

πŸ“„ License

MIT License


🀝 Contributing

Pull requests, bug reports, and feature suggestions are welcome.


⭐ Status

Property Value
Version 1.2.0
Stability Production Ready
Target Blazor WebAssembly
Scope Client-side IndexedDB ORM

Made with ❀️ for the Blazor community

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 47 5/28/2026
1.1.0 125 5/14/2026 1.1.0 is deprecated because it has critical bugs.
1.0.0 125 5/13/2026 1.0.0 is deprecated because it has critical bugs.