aspnetzero-multitenancy-patterns

Implements multi-tenancy entity, permission, and testing patterns for ASP.NET Zero applications.

Updated May 22, 2026
One-click install
npx skills add https://github.com/shakesoft/timekeeper --skill aspnetzero-multitenancy-patterns-shakesoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: aspnetzero-multitenancy-patterns
Source: https://github.com/shakesoft/timekeeper/tree/main/.cursor/skills/aspnetzero-multitenancy-patterns
Command: npx skills add https://github.com/shakesoft/timekeeper --skill aspnetzero-multitenancy-patterns-shakesoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers building multi-tenant applications on ASP.NET Zero often misconfigure tenant scoping, forget to set TenantId on entities, or assign permissions to the wrong tenancy side, causing data leaks between tenants. ## Core Features & Use Cases - Entity Tenant Scoping: Guides correct use of IMustHaveTenant and IMayHaveTenant interfaces so ABP automatically filters queries by TenantId. - Permission Side Configuration: Shows how to restrict permissions to host-only or tenant-only using multiTenancySides in AppAuthorizationProvider. - Testing Patterns: Provides [MultiTenantFact] test examples that verify TenantId is correctly persisted. - Use Case: When adding a new Product entity to a SaaS app, follow the checklist to implement IMustHaveTenant, set TenantId from AbpSession in the create method, and scope the permission to tenants only. ## Quick Start Ask the assistant to create a new tenant-scoped entity with its app service and permissions following ASP.NET Zero multi-tenancy patterns.

Frequently Asked Questions about aspnetzero-multitenancy-patterns

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

FAQPage Schema
How do I make an entity tenant-scoped in ASP.NET Zero?▼

Implement IMustHaveTenant on the entity when it always belongs to a tenant, or IMayHaveTenant when it can be host-level or tenant-level. ABP then automatically filters queries by the current session's TenantId.

What is the difference between IMustHaveTenant and IMayHaveTenant?▼

IMustHaveTenant uses a required int TenantId for entities that always belong to a tenant. IMayHaveTenant uses a nullable int? TenantId, allowing the entity to exist at host level (null) or belong to a specific tenant.

How do I restrict a permission to host or tenant users in ABP?▼

Pass the multiTenancySides parameter when creating the permission in AppAuthorizationProvider. Use MultiTenancySides.Host for host-only features, MultiTenancySides.Tenant for tenant-only features, or omit it for both.

Why is TenantId null when creating entities in ASP.NET Zero?▼

TenantId is not set automatically during DTO-to-entity mapping. After ObjectMapper.Map, you must manually assign entity.TenantId = AbpSession.GetTenantId() in your create method before inserting.

How do I query data across all tenants in ABP?▼

Wrap the query in a using block with CurrentUnitOfWork.DisableFilter(AbpDataFilters.MustHaveTenant). This temporarily disables automatic tenant filtering so the repository returns records from all tenants.