I'm writing a new ASP.NET Core application (.NET Core 3.1) using EF Core for database access. This application should interface with an existing PostgreSQL database that has a PostgreSQL schema for each tenant. From what I read so far, this is not the way one would usually do this in .NET Core, but as the database already exists I don't have any choice here. I couldn't find any good information on how to dynamically switch schemas, the documentation for multi-tenant database access generally assumes different models than tenant-per-schema or different databases.
The table layout is identical in all schemas, so the only thing that has to happen is that the search_path is set to the correct schema for each request. I'm not sure how to do this exactly with EF Core, the documentation I found only addresses setting the schema statically or per model.
What is the correct way to handle this kind of multi-tenant setup in ASP.NET Core using EF Core?