SaaS CRM with Multi-Tenancy — Complete Source Code
A production-ready multi-tenant SaaS CRM application to serve multiple organizations from a single deployment. Built with .NET 10, ASP.NET Core, Blazor Server, MudBlazor, and Vertical Slice Architecture. Complete tenant isolation, shared database with global query filters.

SaaS businesses need to serve multiple organizations from one deployment — but building secure tenant isolation, managing separate customer data, and scaling multi-tenant infrastructure is complex and expensive.
Building separate CRM instances for each client is prohibitively expensive in infrastructure and maintenance. Blazor CRM Multi-Tenant allows multiple organizations to share one database and one deployment with complete data isolation via TenantId global query filters. Add new tenants in seconds without provisioning new servers.
Without proper tenant isolation, customer data can leak between organizations — a catastrophic security and compliance failure. EF Core global query filters automatically scope every query to the current tenant. Tenant A's contacts, deals, and activities are completely invisible to Tenant B. Zero data leakage by design.
Each tenant needs their own contacts, companies, and deals — but managing this separation manually is error-prone. Blazor CRM Multi-Tenant centralizes all tenant data with automatic scoping. Every API call, every database query, every UI interaction is tenant-aware.
Each tenant needs their own sales pipeline and reporting — but building per-tenant analytics is complex. Blazor CRM Multi-Tenant provides fully tenant-aware dashboards with KPI cards, pipeline charts, and win/loss rates scoped to each organization.
Complete end-to-end business features with multi-tenant isolation — every module is a complete vertical slice with endpoint, handler, validator, and EF Core queries.
Personal Info, Password, Avatar, Session
Campaign, Budget, Expense, Lead, Lead Contacts, Lead Activities, Sales Team, Sales Representative
Customer Group, Customer Category, Customer, Customer Contact, Vendor Group, Vendor Category, Vendor, Vendor Contact
Quotation, Sales Order, Delivery Order, Sales Return, Invoice, Credit Note, Payment, Sales Report, Delivery Report, Return Report, Invoice Report, Payment Report
Requisition, Purchase Order, Goods Receive, Purchase Return, Bill, Debit Note, Payment, Purchase Report, Receive Report, Return Report, Bill Report, Payment Report
Unit Measure, Product Group, Product, Warehouse, Transfer Out, Transfer In, Positive/Negative Adjustment, Scrapping, Stock Count, Transaction Report, Stock Report, Movement Report
Booking Group, Booking Resource, Booking Manager, Scheduler, Program Resource, Program Manager, To-Do List
Database log, File log
Users, Currencies, Auto Number
full inspection mode for appsettings.json
Blazor CRM Multi-Tenant is built on the modern .NET ecosystem with production-grade libraries and tools.
| Layer | Technology |
|---|---|
| Framework | .NET 10 |
| Web Framework | ASP.NET Core 10 |
| UI Rendering | Blazor Server (SignalR-based real-time UI) |
| UI Component Library | MudBlazor (Material Design components for Blazor) |
| Architecture Pattern | Vertical Slice Architecture (VSA) + CQRS via MediatR |
| Multi-Tenancy | EF Core Global Query Filters with TenantId isolation |
| API Style | ASP.NET Core Minimal APIs with Swagger/OpenAPI |
| Data Access | Entity Framework Core 10 (Code-First, Migrations, Compiled Queries) |
| Database | SQL Server (fully tested) / PostgreSQL (scaffolded) |
| Validation | FluentValidation |
| Authentication | ASP.NET Core Identity + JWT Bearer Token |
| Authorization | Role-Based (RBAC) + Policy-Based Authorization |
| Real-Time | SignalR (built into Blazor Server) |
Blazor CRM Multi-Tenant uses Vertical Slice Architecture (VSA) with CQRS via MediatR and EF Core global query filters for complete tenant isolation.
Each feature (Create Tenant, Get Contact, Update Deal, etc.) lives in its own folder with its Minimal API endpoint, MediatR handler, FluentValidation validator, and EF Core queries all in one place. Zero coupling between features. Every handler automatically applies tenant filtering.
Folder structure: Features/Tenants/CreateTenant/ contains endpoint, handler, validator, DTO — everything for that single operation with tenant awareness built in.
Tenant isolation is implemented at the EF Core level using global query filters. Every entity has a TenantId property, and EF Core automatically applies .Where(e => e.TenantId == currentTenantId) to all queries. Zero data leakage by design — no developer can accidentally query across tenants.
Tenant resolution: Determined from the authenticated user's claims, applied to DbContext at request scope.
The entire multi-tenant application — Blazor UI, REST API, tenant management, business logic, data access, and authentication — lives in one .NET 10 project. No distributed complexity, no microservice overhead. Single F5 to run. Deploy as one unit to Azure, IIS, or Docker. Perfect for SaaS startups that value velocity.
BlazorCRMMultiTenant/
├── Features/ # Vertical Slices (one folder per feature)
│ ├── Tenants/
│ │ ├── CreateTenant/ # Endpoint + Handler + Validator + DTO
│ │ ├── GetTenantList/
│ │ └── UpdateTenant/
│ ├── Contacts/
│ ├── Companies/
│ ├── Deals/
│ ├── Leads/
│ ├── Activities/
│ └── Dashboard/
├── Infrastructure/ # Cross-cutting: Auth, Audit, Tenant Resolution, EF Core
├── Migrations/ # EF Core migrations
├── SeedData/ # Initial seed data (demo tenants, users, sample data)
├── Components/ # Shared Blazor components
├── wwwroot/ # Static assets
└── Program.cs # Single entry point with tenant-aware configuration
Security is baked into the architecture — multi-tenant isolation, Identity, JWT, RBAC, and audit trail.
Blazor CRM Multi-Tenant ships with tenant-aware authentication and authorization. ASP.NET Core Identity manages users per tenant with secure password hashing. JWT authentication protects all REST API endpoints, while cookie-based authentication handles Blazor Server UI. Both schemes run simultaneously and are tenant-scoped.
Role-based access control (RBAC) is fully tenant-scoped: each tenant has their own Admin, Manager, and User roles. Policy-based authorization provides fine-grained control. EF Core global query filters guarantee that Tenant A's data never leaks to Tenant B — enforced at the database level.
With Blazor Server, source code, database credentials, and tenant resolution logic never leave the server. All data access happens server-side via SignalR.
Blazor CRM Multi-Tenant exposes a complete tenant-aware REST Web API — ready for mobile apps, third-party integrations, and external systems.
Every feature exposes REST endpoints via ASP.NET Core Minimal APIs. All endpoints are JWT-protected and automatically scoped to the authenticated user's tenant.
Same tenant-aware pattern applies to all entities: Companies, Deals, Leads, Activities, and Dashboard aggregations.
/swaggerEF Core migrations, seed data with demo tenants, and flexible deployment options — ready to run in under 60 seconds.
Explore the Blazor CRM Multi-Tenant interface — tenant management, dashboards, contact management, sales pipeline, and more.
Test every feature — including multi-tenant isolation — before you buy. No registration required.
Complete, unrestricted C# source code with full multi-tenant SaaS architecture. Single .NET 10 project. Clone, F5, serve multiple tenants.
Secure checkout via Lemon Squeezy. Lifetime access. No subscription.
TenantId on every entity. When a user authenticates, their tenant is resolved from claims. EF Core automatically applies .Where(e => e.TenantId == currentTenantId) to all queries. Zero data leakage between tenants. Each tenant has isolated users, contacts, deals, and dashboards — all in one database.