Base solution for your next web application
Open Closed

Change connection string dynamically for user #4655


User avatar
0
princedis created

Hi,
I am using AspNet Zero version 3.0.0 and I would like to give users the option to switch database for testing in our organization. I have enabled LDAP so cannot enable Multi Tenancy. I was able to change the connection string dynamically by creating a custom ConnectionStringResolver and by extending AbpSession to store the current database selection of the user. But when one user changes the database it is changed for all users in the organization. I would like to change the database separately for each user based on their preference. If I would create a user setting I would have to use Ado.net to check the setting because of different databases.

Is there any other way to change the connection string dynamically for a user?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @princedis why don't you use a user scoped setting for this ? In your custom ConnectionStringResolver , you can first switch to default tenant's database (CurrentUnitOfWork.SetTenantId(1)), then use settingManager.GetSettingValueForUser to retrieve correct connection string.