• Stars
    star
    182
  • Rank 204,404 (Top 5 %)
  • Language
    C#
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Multitenant ASP.NET Core application to serve as a starting point for real multitenant applications

Multi-tenant ASP.NET Core

This is demo project for my Multi-tenant ASP.NET Core presentation. It demonstrates multi-tenant solutions I have worked out for ASP.NET Core. I'm using the same demo also for presentations. Solutions provided here are not absolute truth. There are cases when something different is needed and then the code here serves as a good starting point.

Features

There are multiple features and solutions demonstrated in demo application:

Setting every thing up

To demonstrate multi-tenant features I have built I'm using SQL Server LocalDB and MySQL databases. SQL Server LocalDB uses integrated security. For MySQL some user account is needed to access database. Those who plan to run this example on Linux must use some Linux version of SQL Server or SQL Server running on some other machine.

There are two web applications in the solution:

  • AspNetCoreMultitenant.Web - safe multitenant web application to use as an example and starting point
  • AspNetCoreMultitenant.WebDangerous - dangerous approach to shared resources (shared database tables)

AspNetCoreMultitenant.Web defines three tenants:

  • bigcorp - uses dedicated MySQL database
  • sme1 - uses SQL Server database
  • sme2 - uses SQL Server database

AspNetCoreMultitenant.WebDangerous defines two tenants:

  • sme1 - uses same SQL Server database as sme2
  • sme2 - uses same SQL Server database as sme1

There are also some host name mappings needed to run this demo on local machine:

  • 127.0.0.1 bigcorp
  • 127.0.0.1 sme1
  • 127.0.0.1 sme2

Web application uses port 5000 and it must be added to URL of all tenants:

Dangerous web application uses port 5001 and it must be added to URL of all tenants:

When using public server to host this application make sure you turn on HTTPS in application startup.

Concepts

This solution has some important concepts to know:

  • Tenant source - class that knows how to read tenant definitions from tenants store
  • Tenant provider - class that knows how to find current tenant
  • Dynamic cache key provider - class that provides EF Core with caching keys for DbContext model
  • Missing tenant middleware - ASP.NET Core request pipeline middleware that acts when tenant is not found

More Repositories

1

AspNetCoreTests

Simple, clean and minimalistic ASP.NET Core solution demonstrating unit and integration tests
C#
109
star
2

DotNetPaging

Data paging with ASP.NET and ASP.NET Core
JavaScript
80
star
3

BlazorDemo

Demo application for my writings about Blazor
C#
79
star
4

AspNetCoreChatRoom

WebSocket based chat room built on ASP.NET Core
C#
52
star
5

Visual-Studio-Experiments

Source code of my Visual Studio experiments
JavaScript
40
star
6

AspNetCoreRealTimeChart

Example of real-time chart on ASP.NET Core using WebSocket
C#
33
star
7

TemperatureStation

Simple temperature measuring system
CSS
16
star
8

AspNetCorePowerBI

Embedded Power BI reports in ASP.NET Core
C#
15
star
9

AspNetCoreLocalization

C#
12
star
10

EFCoreGlobalQueryFilters

C#
10
star
11

CognitiveServicesDemo

Demo application for my Azure Cognitive Services Vision API presentation
JavaScript
9
star
12

ObjectToObjectMapper

Source code for my posts serie about building object-to-object mapper
C#
8
star
13

Windows-Phone-7-Experiments

My Windows Phone 7 experiments and examples
C#
6
star
14

AspNetCoreBearerTokenAuth

C#
6
star
15

Windows10IoTWebControl

Windows 10 IoT Core background task that is controllable through ASP.NET Core web application on same board.
C#
5
star
16

BlazorBeerCalculator

Blazor based offline WebAssembly application to calculate alc. vol. of beer.
JavaScript
4
star
17

DapperDemo

Samle to-do application using ASP.NET Core and Dapper
C#
4
star
18

RazorClassLibraryDemo

Example of Razor Class Library using ASP.NET Core MVC.
C#
3
star
19

AspNetCoreHelloBlinky

Source code for my ASP.NET Core 3.0 "Hello, blinky" IoT application
C#
3
star
20

HierarchyTraverser

HierarchyTraverser is universal class for traversing hierarchies.
C#
2
star
21

spfx-harjutused

SharePoint Framework (SPFx) koolituse raames tehtud harjutused
JavaScript
2
star
22

JekyllBlog

Sample static blog built on Jekyll and deployed to Azure static website using Azure DevOps
CSS
2
star
23

CSharp7

Support solution for my C# 7.x blog posts and presentation
C#
1
star
24

AspNetCoreMultiplatform

Multiplatform web application written on ASP.NET Core
C#
1
star
25

MyMobileApp

Xamarin Forms multi-platform experiments
C#
1
star
26

WindowsIotTrafficLights

Traffic lights simulator built on Windows 10 IoT Core and RaspberryPi. Implementations for Windows 10 IoT Core background task and UWP appliation.
C#
1
star