Can I choose different DB servers for different tenants?
At https://docs.abp.io/en/abp/latest/Multi-Tenancy#database-architecture, we have found that we can separate the DB for each tenant.
Can I choose different DB servers for different tenants?
Can I achieve the following? https://docs.abp.io/en/commercial/latest/modules/saas#connection-string
- ABP Commercial: v7.1
5 Answer(s)
-
0
Hi,
Sorry, but the ABP framework does not support it
-
0
Thank you very much.
However, it occurs in the future that we want to separate DB instances. As a use case, ・Enterprise companies ・When the number of companies reaches a certain number, we want to split the DB (e.g. 1 DB instance per year)
●Question If we customize ABP Commercial to achieve this, can we get consulting? Also, is the scope of influence of customization quite large?
●workaround Given the current constraints, I would take the following approach ・xxx-2023.portx.cloud → 2023 DB ・xxx-2024.portx.cloud → 2024 DB
-
0
Hi,
This sounds like a DBA thing.
For the code side.
you can dynamically replace the connect string.
Server=localhost;Database=xxx-{year}.portx.cloud ;Trusted_Connection=TrueTrustServerCertificate=True
[Dependency(ReplaceServices = true)] public class MyMultiTenantConnectionStringResolver: MultiTenantConnectionStringResolver { protected ICurrentTenant CurrentTenant { get; } public MyMultiTenantConnectionStringResolver(IOptionsMonitor<AbpDbConnectionOptions> options, ICurrentTenant currentTenant, IServiceProvider serviceProvider) : base(options, currentTenant, serviceProvider) { CurrentTenant = currentTenant; } public async override Task<string> ResolveAsync(string connectionStringName = null) { var connectionString = await base.ResolveAsync(connectionStringName); if (CurrentTenant.IsAvailable) { connectionString = connectionString.Replace("{year}", DateTime.Now.Year.ToString()); } return connectionString; } public override string Resolve(string connectionStringName = null) { var connectionString = base.Resolve(connectionStringName); if (CurrentTenant.IsAvailable) { connectionString = connectionString.Replace("{year}", DateTime.Now.Year.ToString()); } return connectionString; } }
-
0
thank you.
Is it possible to write the DB endpoint in this URL? https://docs.abp.io/en/commercial/latest/modules/saas?&_ga=2.31513790.1017473141.1680852494-480170447.1680614778#connection-string
For example, for a company tenant, I want the host to be a.rds.cloud.
Server=a.rds.cloud;Database=a;Trusted_Connection=TrueTrustServerCertificate=True
-
0
Yes, you can.