I'm trying to extend an older application with a new Web API and GraphQL / Hotchocolate was chosen as the technology to go.
The underlying SQL Server database consists of at least 3 databases. "at least" means, there can be more databases, depending on the amount of tenants, that are managed by the application.
This brings me to the problem, that I can't add the dbcontext services in the ConfigureService method of the Startup class, because the actual tenant is unknown at the time when the startup class is instanciated.
The first of the three databases is always the same, so there is no problem, but database 2 and 3 have slightly different connectionstrings and look like this "...Initial Catalog=TenantStructure{0}..." and "...Initial Catalog=TenantData{0}..." in the appsettings.json.
The suffix "{0}" needs to be replaced by the actual tenantid, which must be somewhere part of the query.
It seems as if I have to open the connections to the structure and data databases at each query and my question is, how I can pass additional informations like the necessary tenantid to the query. As far as I can see, I can't use the tenantid as a filter value.
Thanks for any help.