Hangfire - Multi tenant, single data base with separate schema per tenant - hangfire

How to work with Hangfire - Multi-tenancy separate schema approach. Please suggest or any reference articles.
Storage : SQL Server
Framework: .Net FW 4.8
Single Database for all tenants. But every tenant has his own set of tables with separate schema. I have a master with tenants and their information
Ex: TenantID, Schema, Email etc. A job has to be run for every Tenant, while executing the job I need to know the TenantId, so that I can fetch tenant related schema.

Related

Couchdb 2.0 replicate multiple user databases to single db

I am using couchdb and each user has their own database.
However, I have a web app that should be able to look up an _id in any database and return the document. With thousands of users, querying across thousands of couchdb instances would be impractical.
How can I replicate my data to a single master database so that I can query by _id?
What I ended up doing is replicating every userdb to a master db when the database was created, using the _replicate API endpoint. The master db then contains a read-only copy of all the other databases.

Elastic Db tools and unique indexes

I read the documentation for the Microsoft Elastic DB tools and I wanted to ask what are the best practices for sharing a database with multiple tenants and also using unique index.
Let's say that we have a users table, in which all users for a tenant are saved. We define that the email must be unique for each user. But, If a user is present in 2 tenants and he wants to reuse his email, he can't because the unique index is in place.
In this case, we need to include in the unique index the tenant id. Is this the right approach? In this case we would need to explicitly use the tenant id in all of our queries so that the performance is not affected.
Yes, including the tenant id in each sharded table is a common practice in SaaS programming models. Here is some context on the spectrum of multi-tenant per database to single tenant per database models for SaaS applications: https://learn.microsoft.com/en-us/azure/sql-database/sql-database-design-patterns-multi-tenancy-saas-applications#multitenant-data-models

Can SQL Azure Reporting support a multi-tenancy model discretely/opaquely?

We are storing multiple tenants in one instance of SQL Azure. I have been doing some research, but I cannot determine if SQL Azure Reporting can support a multi-tenant model discretely.
For example, we want to run reports for a user based on their "tenancy", but we want their tenant ID to be completely opaque to them- not contained in a query string, or anything view-able by the user.
Has anyone encountered this problem before? What was your solution?
If you had the restriction that a User can only belong to a single tenant, you can hop from a User to the corresponding tenant without them having to know their tenant Id. So any of your Tenant related queries could automatically be filtered by the logged-in user.

Is Federation ID Predicate just a SQL Azure thing?

Im setting up a multi tenant database and came across the following blog post on federations: SQL Azure Multi Tenant
They write about assigning a predicate to filter data between tenants:
In a single-tenant app, the query logic in application is coded with the assumption that all data in a database belongs to one tenant. With multi-tenant apps that work with identical schemas, refactored code simply injects tenant_id into the schema (tables, indexes etc) and every query the app issues, contains the tenant_id=? predicate. In a federation, where tenant_id is the federation key, you are asked to still implement the schema changes. However federations provide a connection type called a FILTERING connection that automatically injects this tenant_id predicate without requiring app refactoring. Our data-dependent routing sets up a FILTERING connection by default. Here is how;
1: USE FEDERATION orders_federation(tenant_id=155) WITH RESET, FILTERING=ON
My question is, is this just a SQL azure thing? Or can this be accomplished with any sql server instance?
Thanks in advance
Federations are available only on SQL Azure.

Entities and multiple databases

We've got the following scenario:
Central Database (replicated across multiple servers)
Client Database 1
Client Database 2
The Central db has Users and Roles amongst other things
The Client dbs have similar tables to each other but with some fields tweaked - contact, address, etc...
At present, each client db has its own user/role information which is copied from the central db by a scheduled process. I want to retrieve the user/role information directly from the central db instead (bearing in mind tables in the client db make reference to the user entity)
Is this even possible? If not, what's a better approach for having central user configuration across multiple databases?
Does this mean that you have referential integrity between tables?
bearing in mind tables in the client
db make reference to the user entity
If yes, as long as you have referential integrity between tables they must be in the same database. That points to your current solution being the best.
If no then linked tables would be the way to go, the tables would appear to be local, but the data would be retrieved from the cental database each time.
You EF4 will also not generate linked tables.
Your other option would to go for a more service orientated architecture, creating a user service connected to a web service. But this is probably a lot of work.