Quick Start Guide

Get up and running with REDB in minutes

~10 min
Fastest way SQLite with Pro: no database server, no license key
$ dotnet new install redb.Templates
$ dotnet new redb -n MyApp
$ dotnet run --project MyApp

A console app with CRUD, queries and a tree. The database is created as a file next to the app on the first run.

Pick a starting point

Seven templates in one pack. Each runs as is; the route-based ones deploy in their own host or as a Tsak module.

Console app redb

Create, load, update, query and a tree: the basics of RedBase in one Program.cs.

--db sqlite|postgres|mssql, --pro true|false

dotnet new redb -n MyApp
Details →
Razor Pages site redb-razor

A product list with search, sorting and paging in the database, and a create / edit form.

SQLite Pro; PostgreSQL or SQL Server through compose

dotnet new redb-razor -n MySite
Details →
Blazor site redb-blazor

The same list and form as an interactive Blazor Server site, plus a category tree.

SQLite Pro; PostgreSQL or SQL Server through compose

dotnet new redb-blazor -n MySite
Details →
Integration worker redb-worker
Tsak

Files from a folder, an XSD check, one transaction in RedBase, a receipt back. Duplicates are caught by a unique key.

SQLite Pro; SFTP, AS2 or SQL as the source in one line

dotnet new redb-worker -n MyWorker
Details →
LLM chat redb-chat
Tsak

A chat on redb.Route.Llm with the history in RedBase, in the console and over HTTP.

--tools none|shell|mcp, --audit true|false

dotnet new redb-chat -n MyChat
Details →
Blazor WebAssembly app redb-app
Tsak

A WebAssembly client and a REST DSL API with sign-in by JWT: products, a form, a category tree.

SQLite Pro; nginx serves the client and forwards /api/

dotnet new redb-app -n MyApp
Details →
Blazor BFF redb-bff
Tsak

A Blazor Server front with a cookie session and a backend of redb.Route controllers behind a service key.

SQLite Pro; the backend is reachable only from the web server

dotnet new redb-bff -n MyApp
Details →
PVT prefilter On: a selective filter does not read the whole scheme.
Change tracking On: a save writes only the fields that changed.
Docker and compose A Dockerfile and compose files for PostgreSQL and SQL Server.
Own host or Tsak A route-based module runs in either one.

All templates: options, what is inside, run and deploy →

This guide covers the essential CRUD operations: Create, Read, Update, Delete, and Query. Follow along to build your first REDB-powered application.

1

Installation

Install REDB packages via NuGet. Choose your database provider:

bash
# For PostgreSQL
dotnet add package redb.Postgres

# For SQL Server
dotnet add package redb.MSSql

# For SQLite (embedded / offline / Blazor WASM / mobile)
dotnet add package redb.SQLite        # Free (native extension)
dotnet add package redb.SQLite.Pro    # Pro (pure C# — WASM / mobile)

# For Pro features (advanced queries, bulk operations)
dotnet add package redb.Postgres.Pro
dotnet add package redb.MSSql.Pro
2

Configuration

Register REDB services in your Program.cs:

csharp
// Free version
services.AddRedb(options => options
    .UsePostgres("Host=localhost;Database=mydb;Username=user;Password=pass"));

// Pro version (no license key required since 3.3.0)
services.AddRedbPro(options => options
    .Configure(c =>
    {
        c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking;
        //c.EnablePropsCache = false;
        //c.PropsCacheMaxSize = 10000;
        //c.PropsCacheTtl = TimeSpan.FromMinutes(60);
    })
    .UsePostgres("Host=localhost;Port=5432;Username=postgres;Password=***;Database=redb;Pooling=true;Include Error Detail=true;Options=-c jit=off")
    //.UseMsSql("Server=localhost;Database=redb;User Id=sa;Password=***;TrustServerCertificate=true;Command Timeout=600;")
    //.UseSqlite("Data Source=app.db")   // embedded; Pro tier runs in Blazor WASM / mobile
    );
3

Define Your Model

Create a Props class with the [RedbScheme] attribute. This is your business entity - no database tables to create, no migrations to write:

csharp
using redb.Core.Attributes;

[RedbScheme("Product catalog")]
public class ProductProps
{
    public string Name { get; set; } = "";
    public string? Description { get; set; }
    public decimal Price { get; set; }
    public string[] Tags { get; set; } = [];
    public bool IsActive { get; set; } = true;
}
4

Create - SaveAsync

Create and save a new object. The SaveAsync method returns the generated ID:

csharp
var product = new RedbObject<ProductProps>
{
    name = "Widget Pro base name",
    Props = new ProductProps
    {
        Name = "Widget Pro",
        Description = "A professional widget",
        Price = 99.99m,
        Tags = ["electronics", "tools"],
        IsActive = true
    }
};

var id = await redb.SaveAsync(product);
// id now contains the generated object ID
5

Read - LoadAsync

Load an object by its ID. Returns the complete object with all properties:

csharp
var loaded = await redb.LoadAsync<ProductProps>(id);

// Access properties
var name = loaded.Props.Name;
var price = loaded.Props.Price;

// or
if (loaded != null) {
    var product = (ProductProps)loaded;
    var name = product.Name;
    var price = product.Price;
}
6

Query - Where

Filter data using familiar LINQ syntax. All conditions compile to native SQL:

csharp
// Simple filter
var expensive = await redb.Query<ProductProps>()
    .Where(p => p.Price > 75000m)
    .Take(100)
    .ToListAsync();

// AND condition
var filtered = await redb.Query<ProductProps>()
    .Where(p => p.Price >= 30 && p.Price < 100)
    .ToListAsync();

// OR condition
var mixed = await redb.Query<ProductProps>()
    .Where(p => p.Price < 10 || p.Price > 90000m)
    .ToListAsync();

// NOT equal
var notWidgets = await redb.Query<ProductProps>()
    .Where(p => p.Name != "Widget")
    .ToListAsync();
7

Count - CountAsync

Get the count of objects matching your criteria:

csharp
// Total count
var totalCount = await redb.Query<ProductProps>().CountAsync();

// Filtered count
var activeCount = await redb.Query<ProductProps>()
    .Where(p => p.IsActive)
    .CountAsync();
8

Delete - DeleteAsync

Remove an object by ID. The object is permanently deleted:

csharp
// Delete by ID
await redb.DeleteAsync(id);

// Verify deletion
var deleted = await redb.LoadAsync<ProductProps>(id);
// deleted will be null

Next Steps