Tenant Connection-string switching Information
Hello,
We are not able to understand when we change the tenant from UI how it will use the provided connection string from code perspective.
where is the code in tenant or in the different modules we would like to know?
Let's say:
when I am login without specifying the tenant it uses the default connection string provided in appSettings.json.
but when I specify the name of tenant it will use there own connection string right. so where the connection string is switching we would like to know the location/filename.
It will would be great if anyone provide the document for the same.
Thanks in Advance.
See https://docs.abp.io/en/abp/latest/Connection-Strings
Hi @liangshiw ,
I have Implemented in http.host project for demo purpose only.
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
namespace Test.Demo
{
[Dependency(ReplaceServices = true)]
public class connectionTest : IConnectionStringResolver, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
private readonly IServiceProvider _serviceProvider;
public connectionTest(
IOptionsSnapshot<AbpDbConnectionOptions> options,
ICurrentTenant currentTenant,
IServiceProvider serviceProvider)
{
_currentTenant = currentTenant;
_serviceProvider = serviceProvider;
}
public string Resolve(string connectionStringName = null)
{
return "Server=(local)\\SQLEXPRESS_2016;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true";
}
}
}
and resolve the dependency
context.Services.Replace(ServiceDescriptor.Transient<IConnectionStringResolver, connectionTest>());
so I have implemented this way, but now the issue is I am getting debug point in every 1 minute without any activity, don't know why can you please me.
Thanks in advance.
Some background workers will call repository method. You should look at the call stack.
Hello @liangshiw ,
we have created the whole new project and then copy the same above code still, we are getting the hit again and again (debug point)
I think this is an issue because whatever the things provided in the documentation we are following but still not able to resolve the issue.
@liangshiw Please check the call stack.

Some background workers will call repository method, you can see the BackgroundJobWorker.

This is the design, If you don't need background jobs, you can disable the background job system.