gpeipman/AspNetCoreMultitenant
关于
Multitenant ASP.NET Core application to serve as a starting point for real multitenant applications
数据与分析可以做什么
- Using database per tenant strategy
- Using shared database for tenants
- Multi-tenant EF Core database context with security net
- Loading tenants configuration
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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:
- Using database per tenant strategy
- Using shared database for tenants
- Multi-tenant EF Core database context with security net
- Loading tenants configuration
- Missing tenant middleware
- Tenants provider to get current tenant
- Tenant-based dependency injection
- Unit-testing multi-tenant database context (coming soon)
- Multi-tenant configurable composite commands
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
探索相关项目
加载中…