Multitenancy Techniques for ASP.NET Core
Introduction This will be another post on the multitenancy subject. For now, I plan to write or already wrote: Tenant identification (this article) Data filtering (for EF Core) UI customisation Business logic If you've been following this blog, you know about data filtering with EF Core as an example. This time, I will focus on tenant identification. A tenant is identified by some id. It may have some data, configuration, etc, against it, but, for now, we just want to be able to identify who it is. Tenant Identification When it comes to identifying a tenant, there are some options: A query string parameter (mostly for testing) A route part An HTTP header A JWT token property A cookie A single tenant will be associated with a request, and it won't change during its processing, so we just need to obtain the tenant id first and possibly store it somewhere. Let's reuse the same interface as before: public interface ITenantIdProvider { str...