Resolving the tenant can be done in several ways:
For our point-of-sale solution, we chose the hostname approach. For our use-case, this gave each client their own “home” from a UI perspective, which felt to be the best approach. Here is the base code to perform tenant resolution. The basics here are that we resolve the tenant id from the hostname, and use it as the key for performing a lookup in the database to get the connection information to the client’s database:
Within several other portions of our system, such as the service where each store would connect to our server environment, we needed a standard connection url to make configuration easier for VARs and clients alike. For these instances, we resolve the current claims principal from the request’s context, and extract out their tenant id from its claim. Once we have that identifier, we can then build the connection to the database.