-
Notifications
You must be signed in to change notification settings - Fork 161
Sharding: Move Tenant to database
There is only one extra Tenant Admin command when you are using many-databases structure (e.g. when the TenantType
property in the AuthP options has the AddSharding
member added) is the MoveToDifferentDatabaseAsync
. This method does two things:
- It can move the tenant's data to another database, defined by the connection string names.
- It can change the tenant's
HasOwnDb
property, which will change whether the tenant has its own database or not. Note the you can just changed theHasOwnDb
property, then it changes the database arrangement.
This means you can:
- A tenant in a shared database (i.e. many tenants in one database) can be moved into a database that is only by this tenant (known as a shard) for better performance / security, but more cost for the extra database.
- A tenant in its own database (sharding) can be moved into a shared database with other tenants in the same database. This is cheaper, but the individual performance / security of the moved tenant is slower.
NOTE: In Azure's SQL Server elastic pool this is known as split-merge.
The MoveToDifferentDatabaseAsync
method is easy to use, but be aware implementing the code your tenant change service is quite difficult to write. See the MoveToDifferentDatabaseAsync
implementation in the ShardingTenantChangeService, which is a simple move. Real databases would need much more work to create the code to move a tenant in a shared database (i.e. many tenants in a single database) into its own database, or visa-versa.
- Intro to multi-tenants (ASP.NET video)
- Articles in date order:
- 0. Improved Roles/Permissions
- 1. Setting up the database
- 2. Admin: adding users and tenants
- 3. Versioning your app
- 4. Hierarchical multi-tenant
- 5. Advanced technique with claims
- 6. Sharding multi-tenant setup
- 7. Three ways to add new users
- 8. The design of the sharding data
- 9. Down for maintenance article
- 10: Three ways to refresh claims
- 11. Features of Multilingual service
- 12. Custom databases - Part1
- Videos (old)
- Authentication explained
- Permissions explained
- Roles explained
- AuthUser explained
- Multi tenant explained
- Sharding explained
- How AuthP handles sharding
- How AuthP handles errors
- Languages & cultures explained
- JWT Token refresh explained
- Setup Permissions
- Setup Authentication
- Startup code
- Setup the custom database feature
- JWT Token configuration
- Multi tenant configuration
- Using Permissions
- Using JWT Tokens
- Creating a multi-tenant app
- Supporting multiple languages
- Unit Test your AuthP app