Good afternoon, today I have a multi-tenancy database with 10 clients, I would like to separate 3 clients from this base and put them in another one. Of course, I will duplicate the environment, but regarding the data migration issue, is there a tool that makes it easier? A step-by-step guide to do it?
1 Answer(s)
-
0
Hi @Paulo.bietkoski
There’s no built in tool in ASP.NET Zero that automatically separates specific tenants and their related data into another database. However, you can achieve this by following these steps:
Duplicate the environment As you mentioned, set up a new instance (API, database, and frontend) for the separated tenants.
Backup your existing database Always start by taking a full backup of your current multi tenant database.
Migrate selected tenants’ data
- You can script the migration manually using SQL, exporting all records related to the target tenant IDs.
- Be sure to include all tenant specific tables (those containing a
TenantIdcolumn). - Tools like SQL Server Data Tools, Redgate SQL Data Compare, or even DbForge Data Compare can help automate and validate this process.
Clean up dependencies
- Ensure that any records without
TenantIdthat are required by those tenants (e.g., edition info, language texts, settings) also exist in the new database.
Update connection and tenant configuration Point the separated tenants’ connection to the new database in your configuration (depending on your setup, either
appsettings.jsonorTenantConnectionStringstable).Please feel free to reach out if you need any help during the process. We’ll be happy to assist you.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)