dotnet-multi-tenant

Implement multi-tenant .NET APIs with per-tenant database isolation and JWT secrets.

Updated Jun 20, 2025
One-click install
npx skills add https://github.com/emaginebr/BazzucaMedia --skill dotnet-multi-tenant
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-multi-tenant
Source: https://github.com/emaginebr/BazzucaMedia/tree/main/.claude/skills/dotnet-multi-tenant
Command: npx skills add https://github.com/emaginebr/BazzucaMedia --skill dotnet-multi-tenant

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a robust framework for implementing multi-tenancy in .NET applications, ensuring data isolation, secure authentication, and efficient resource management across different tenants.

Core Features & Use Cases

  • Per-Tenant Database Isolation: Ensures each tenant's data is stored separately.
  • Dynamic JWT Configuration: Manages unique JWT secrets for each tenant for secure authentication.
  • Tenant Resolution: Automatically identifies the tenant from request headers or JWT claims.
  • ACL Layer Propagation: Seamlessly injects tenant context into inter-service communication.
  • Use Case: A SaaS platform needs to onboard new clients (tenants) securely, providing each with their own isolated database and authentication credentials, all managed efficiently through a .NET backend.

Quick Start

Use the dotnet-multi-tenant skill to implement tenant middleware and resolve tenant context from the X-Tenant-Id header.

Frequently Asked Questions about dotnet-multi-tenant

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement multi-tenancy in a .NET API with per-tenant database isolation?

Multi-tenancy in a .NET API is implemented using a dynamic DbContext factory and middleware to route each tenant to a separate database, ensuring strict data isolation across authenticated clients.

How does tenant resolution work with JWT claims and request headers in .NET?

Tenant resolution works by automatically identifying the tenant from the X-Tenant-Id request header or parsing JWT claims, then propagating this context through middleware to isolate data access.

Can I use different JWT secrets for each tenant in a .NET application?

Yes, dynamic JWT configuration allows managing unique JWT secrets for each tenant, enabling secure per-tenant authentication and preventing cross-tenant token misuse within the same application.

What is the best way to propagate tenant context across inter-service API calls in .NET?

Propagating tenant context across inter-service calls is handled seamlessly by injecting an ACL layer using a DelegatingHandler, automatically forwarding the resolved tenant identity to downstream services.

Do I need a dedicated middleware to manage tenant context in a multi-tenant SaaS .NET platform?

Yes, dedicated middleware is required to resolve tenant context from incoming requests and coordinate with the dynamic DbContext factory, securely onboarding new clients with isolated databases and credentials.