Skip to main content

Multi-tenancy Lab

Visualize and test enterprise-grade tenant isolation and resolution strategies.

Simulated
Multi-Tenancy
Mode: Simulated
This lab runs fully in simulation mode. No backend required.

1. Architecture Boilerplate

Generate the foundation for Your SaaS multi-tenancy model.

.NET
.NET 8
Node
Node.js
ID
Identity
LOG
Logging
ACL
RBAC
MSG
Notifications
FLG
Flags
AI
AI
STR
Storage
PAY
Payments
SEC
Scanner
DOC
Docs
MTN
Multi-Tenant

Generated Code

// Program.cs
builder.Services.AddPrimusMultiTenancy(options => {
// Choose resolution strategy: Subdomain, Header, or Path
options.ResolutionStrategy = TenantResolutionStrategy.Subdomain;

// Data isolation approach
options.IsolationStrategy = TenantIsolationStrategy.SchemaPerTenant;

// Connection string template for isolated DBs
options.ConnectionStringTemplate = "Server=.;Database=Primus_{TenantId};Trusted_Connection=true;";

// Enable tenant caching for performance
options.EnableTenantCache = true;
options.TenantCacheDuration = TimeSpan.FromMinutes(10);
});

// Middleware setup (order matters)
app.UsePrimusTenantResolution();
app.UsePrimusTenantContext();

// Access current tenant in your services
public class MyService {
private readonly ITenantContext _tenant;

public MyService(ITenantContext tenant) {
_tenant = tenant;
}

public async Task DoWork() {
var tenantId = _tenant.Current.Id;
var schema = _tenant.Current.Schema;
// Queries automatically scoped to tenant
}
}

2. Isolation Simulator

Test how Primus resolves tenants and routes data interactively.

Tenant Resolution Config

Shared DB
Schema Isolation
Full Isolation
DB per Tenant
subdomain
header
path

Resolution Analysis

TRACER-ID: 1773330993703

# Waiting for incoming request signal...

# Simulator will trace context propagation and DB selection