CodEaisy.TinySaas 1.0.0-rc3

This is a prerelease version of CodEaisy.TinySaas.
There is a newer version of this package available.
See the version list below for details.
dotnet add package CodEaisy.TinySaas --version 1.0.0-rc3
NuGet\Install-Package CodEaisy.TinySaas -Version 1.0.0-rc3
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="CodEaisy.TinySaas" Version="1.0.0-rc3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodEaisy.TinySaas --version 1.0.0-rc3
#r "nuget: CodEaisy.TinySaas, 1.0.0-rc3"
#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.
// Install CodEaisy.TinySaas as a Cake Addin
#addin nuget:?package=CodEaisy.TinySaas&version=1.0.0-rc3&prerelease

// Install CodEaisy.TinySaas as a Cake Tool
#tool nuget:?package=CodEaisy.TinySaas&version=1.0.0-rc3&prerelease

TinySaas

GitHub Workflow Status Nuget (with prereleases) Nuget

TinySaas is a C# library for building multitenant applications with .NET Core 3.0+

Supported Use Cases

  • Per-Tenant Services
  • Shared Tenant Services
  • Schema per Tenant (Data Isolation)
  • Database per Tenant (Data Isolation)
  • Shared Database (Data Isolation)

Quickstart

dotnet add package CodEaisy.TinySaas --version 1.0.0-rc3
  • In Startup.cs, add the following inside the ConfigureServices method.

      public void ConfigureServices(IServiceCollection services)
      {
          // register all global singleton services here, and also dependencies for your TenantStore and ResolutionStrategy if any
    
          // ...
    
          // OPTION 1
          services.AddMultiTenancy<Tenant, TenantStore<Tenant>, ResolutionStrategy>();
    
          // OPTION 2
          // uses default `CodEaisy.TinySaas.Model.TinyTenant` as tenant model
          services.AddMultiTenancy<TenantStore<TinyTenant>, TenantResolutionStrategy>();
    
          // ...
    
          // services.AddControllers();
      }
    

    NB: Option 1 - Tenant must implement CodEaisy.TinySaas.Interface.ITenant TenantStore and TenantResolutionStrategy must implement CodEaisy.TinySaas.Interface.ITenantStore and CodEaisy.TinySaas.Interface.ITenantResolutionStrategy respectively.

    Then, add the following in the Configure method

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
    
        // enable multitenant support, with missing tenant handler and tenant container
    
        // OPTION 1
        // missing tenant handler has a dependency that can be provided immediately
        app.UseMultitenancy<Tenant, MissingTenantHandler, MissingTenantOptions>(missingTenantOptions);
    
        // OPTION 2
        // missing tenant handler does not have a dependency or dependency is already registered in services
        app.UseMultitenancy<Tenant, MissingTenantHandler>();
    
        // OPTION 3
        // Use `SimpleTenant` as tenant model, and missing tenant handler does not have a dependency or dependency is already registered in services
        app.UseMultitenancy<TMissingTenantHandler>()
    
        // ...
    }
    
  • In Program.cs, add the following in the CreateHostBuilder method.

    public static IHostBuilder CreateHostBuilder(string[] args) =>
          Host.CreateDefaultBuilder(args)
              .ConfigureWebHostDefaults(webBuilder =>
              {
                  webBuilder.UseStartup<Startup>();
              })
              // OPTION 1: add multitenant support via TenantStartup class
              .ConfigureMultiTenancy<TenantStartup, Tenant>();
              // OPTION 2: add multitenant support via static method
              .ConfigureMultiTenancy<Tenant>(ClassName.StaticMethodName);
    

    NB: TenantStartup must implement IMultiTenantStartup ClassName.StaticMethodName must be of type System.Action<TTenant, Autofac.ContainerBuilder> where TTenant implements ITenant

Requirements

ASP.NET Core 3.0+

Changelog

Learn about the latest improvements.

Credits

Gunnar Peipman and Michael McKenna for their awesome works on Saas in ASP.NET Core.

Want to help ?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CodEaisy.TinySaas:

Package Downloads
CodEaisy.TinySaas.AspNetCore

TinySaas ASP.NET Core extension library

CodEaisy.TinySaas.Auth

A set of authentication helpers for TinySaas

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 663 11/14/2020
1.0.0-rc4 381 7/13/2020
1.0.0-rc3 323 7/13/2020
1.0.0-rc2 429 7/13/2020
1.0.0-rc1 442 7/12/2020