Database name passed on auth request

Hi all, I’ll try to describe my situation before asking my question: my customer has a sql server with 5 databases (one for each internal company department).
I have to develop a webapp on top of these databases to allow employees to work with a single tool but my customer is worried about every change on his server.
These databases need to remain separated, my customer allowed me to just add the minimum tables I need for the users authentication on each db; so my question: could be possible to initialize the db server connection just after I get the db name (server ip/user/password are always the same) from the auth/credentials request?

I didn’t see anything about it… in every example that I’ve seen the db connection is initialized in the AppHost class; are there any pitfalls to initialize it from a “service”?
Where can I initialize the connection in way to correctly propagate it on every service?

I hope I have clearly explained my problem, thank you!

It’s not clear if you only want to change the db connection once for the entire server or once per user request at authentication, or once per user with the db obtained at auth (in which case you’ll need to store it in the Users Session), but have a look at a new feature in v4.0.53 (On MyGet) which lets you change the DB Connection at runtime:

I need to change the db once per user with the db obtained at auth (I’ll save it in user session).

I would like to set only the server ip and the db credentials in my config file, without recompile my app each time a new db is added.