1

In a multi-tenant SaaS application every client has aseparate DB and different connstring value.

I can't have all connstring values in the web.config.

I can retrieve it from the DB and save it in a sessionvariable (on a client login) but I have to carry that value through the layersto the DAL for every request.

Also, the usage of session vars is not recommended inasp.net mvc.

Is there a better way dealing with this issue?

1 Answers1

0

There are several ways to do this but I would do it this way.

1.) Load all DB connection strings and map it to a Client ID based on the SaaS client. You can use a Dictionary

2.) Cache that collection in memory - see How to cache data in a MVC application for further details

3.) Before you hit your DAL resolve the connectionstring for the client.

Community
  • 1
  • 1