SaasSuite.Core 26.3.3.2

dotnet add package SaasSuite.Core --version 26.3.3.2
                    
NuGet\Install-Package SaasSuite.Core -Version 26.3.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SaasSuite.Core" Version="26.3.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SaasSuite.Core" Version="26.3.3.2" />
                    
Directory.Packages.props
<PackageReference Include="SaasSuite.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SaasSuite.Core --version 26.3.3.2
                    
#r "nuget: SaasSuite.Core, 26.3.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SaasSuite.Core@26.3.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SaasSuite.Core&version=26.3.3.2
                    
Install as a Cake Addin
#tool nuget:?package=SaasSuite.Core&version=26.3.3.2
                    
Install as a Cake Tool

SaasSuite.Core

NuGet License: Apache-2.0 Platform

Core abstractions and contracts for building multi-tenant SaaS applications in .NET.

Overview

SaasSuite.Core provides the foundational interfaces, models, and services for implementing multi-tenancy in .NET applications. It defines the core contracts for tenant resolution, isolation policies, and tenant context management without imposing specific implementation details.

Features

  • Tenant Resolution: Flexible tenant identification from various sources (HTTP headers, JWT claims, subdomains)
  • Tenant Context Management: Strongly-typed tenant context with extensible properties
  • Isolation Policies: Support for multiple isolation levels (Shared, Dedicated, Hybrid)
  • Tenant Lifecycle: Tenant storage, retrieval, and management operations
  • Maintenance Windows: Schedule and manage per-tenant maintenance periods
  • Telemetry Integration: Enrich monitoring and logging with tenant context

Installation

dotnet add package SaasSuite.Core

Quick Start

1. Register Core Services

var builder = WebApplication.CreateBuilder(args);

// Register SaasSuite.Core services
builder.Services.AddSaasCore();

var app = builder.Build();

// Add tenant resolution middleware
app.UseSaasResolution();

app.Run();

2. Configure Tenant Resolution

using SaasSuite.Core.Interfaces;
using SaasSuite.Core.Services;

// Resolve tenant from HTTP headers
builder.Services.AddSingleton<ITenantResolver>(sp =>
{
    var httpContextAccessor = sp.GetRequiredService<IHttpContextAccessor>();
    return new HttpHeaderTenantResolver(httpContextAccessor);
});

3. Access Tenant Context

using SaasSuite.Core;
using SaasSuite.Core.Interfaces;

app.MapGet("/api/tenant-info", (ITenantAccessor tenantAccessor) =>
{
    var tenant = tenantAccessor.TenantContext;
    
    if (tenant == null)
        return Results.BadRequest("No tenant context");
    
    return Results.Ok(new
    {
        tenantId = tenant.TenantId.Value,
        tenantName = tenant.Name
    });
});

Core Concepts

TenantId

Strongly-typed identifier for tenants with implicit string conversions:

TenantId tenantId = new TenantId("tenant-123");
string id = tenantId; // Implicit conversion

TenantContext

Holds the current tenant information:

public class TenantContext
{
    public TenantId TenantId { get; set; }
    public string Name { get; set; }
    public string Identifier { get; set; }
    public Dictionary<string, object> Properties { get; set; }
}

Isolation Levels

Define how tenant data is isolated:

  • None: No isolation (single-tenant scenarios)
  • Shared: Logical isolation in shared database
  • Dedicated: Physical isolation per tenant
  • Hybrid: Mix of shared and dedicated resources
public class MyIsolationPolicy : IIsolationPolicy
{
    public IsolationLevel GetIsolationLevel(TenantId tenantId)
    {
        // Enterprise tenants get dedicated databases
        if (IsEnterpriseTenant(tenantId))
            return IsolationLevel.Dedicated;
        
        return IsolationLevel.Shared;
    }
    
    public Task<bool> ValidateAccessAsync(
        TenantId tenantId, 
        string resourceId,
        CancellationToken cancellationToken = default)
    {
        // Validate tenant can access resource
        return Task.FromResult(true);
    }
}

Key Interfaces

ITenantResolver

Resolves tenant ID from the current execution context:

public interface ITenantResolver
{
    Task<TenantId?> ResolveTenantIdAsync(CancellationToken cancellationToken = default);
}

ITenantStore

Persistence operations for tenant data:

public interface ITenantStore
{
    Task<TenantInfo?> GetByIdAsync(TenantId tenantId, CancellationToken cancellationToken = default);
    Task<TenantInfo?> GetByIdentifierAsync(string identifier, CancellationToken cancellationToken = default);
    Task SaveAsync(TenantInfo tenant, CancellationToken cancellationToken = default);
    Task RemoveAsync(TenantId tenantId, CancellationToken cancellationToken = default);
}

ITenantAccessor

Access point for the current tenant context:

public interface ITenantAccessor
{
    TenantContext? TenantContext { get; }
}

Maintenance Windows

Schedule maintenance periods for tenants:

using SaasSuite.Core.Interfaces;

public class MaintenanceController : ControllerBase
{
    private readonly IMaintenanceService _maintenanceService;
    
    public MaintenanceController(IMaintenanceService maintenanceService)
    {
        _maintenanceService = maintenanceService;
    }
    
    [HttpPost("schedule")]
    public async Task<IActionResult> ScheduleMaintenance(
        string tenantId, 
        DateTime startTime, 
        int durationMinutes)
    {
        await _maintenanceService.ScheduleMaintenanceAsync(
            new TenantId(tenantId),
            startTime,
            TimeSpan.FromMinutes(durationMinutes));
        
        return Ok();
    }
    
    [HttpGet("is-under-maintenance")]
    public async Task<IActionResult> CheckMaintenance(string tenantId)
    {
        var isUnderMaintenance = await _maintenanceService
            .IsUnderMaintenanceAsync(new TenantId(tenantId));
        
        return Ok(new { underMaintenance = isUnderMaintenance });
    }
}

Telemetry Enrichment

Enrich logs and metrics with tenant context:

public class TenantTelemetryEnricher : ITelemetryEnricher
{
    public void Enrich(IDictionary<string, object> telemetryData, TenantContext context)
    {
        telemetryData["TenantId"] = context.TenantId.Value;
        telemetryData["TenantName"] = context.Name;
        telemetryData["IsolationLevel"] = context.Properties
            .TryGetValue("IsolationLevel", out var level) ? level : "Unknown";
    }
}

Multi-Framework Support

SaasSuite.Core targets:

  • .NET 6.0 (LTS)
  • .NET 7.0
  • .NET 8.0 (LTS)
  • .NET 9.0
  • .NET 10.0

License

This package is licensed under the Apache License 2.0. See the LICENSE file in the repository root for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on SaasSuite.Core:

Package Downloads
SaasSuite.Discovery

Service discovery and manifest generation for SaasSuite tenant services

SaasSuite.Metering

Usage metering and tracking for multi-tenant SaaS applications

SaasSuite.Quotas

Quota management and enforcement for multi-tenant SaaS applications

SaasSuite.Migration

Multi-tenant data migration engine for SaasSuite

SaasSuite.Secrets

Abstractions and contracts for tenant-aware secret management in multi-tenant SaaS applications

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.3.3.2 41 3/3/2026