Reputation: 1
Our requirement is to have a multi-tenant separate database architecture for a ASP.Net website. For each tenant there will be separate database and depending on UserId, at runtime it should be decided which database to connect. The code is already in production and I am not willing to go with adding a TenantId column in each table and similar code changes in .Net code. Is there a solution in which we can create partitions in SQL Server db and UI should connect to the corresponding partition dynamically. As of now, approach I have in mind is to cache all connection strings and depending on Tenant, select ConnString at runtime.
Upvotes: 0
Views: 676
Reputation: 5249
This may be a bit late depending on how far you are in building your solution, but you could look at the following frameworks:
One thing you can easily do is combine multiple customers in the same database, and associate each customer to a different schema; each user id could be assigned a schema and assign enough rights to the correct schema. Depending on your situation this may make sense. Will you be using Windows Azure/SQL Azure?
The reason I ask about SQL Azure is due to the fact that provisioning new customers becomes much easier, since it can be done programmatically.
Upvotes: 2
Reputation: 19573
If you want to work with your given solution, you'll need a central DB of users and master accounts. The master accounts table will hold the Tenant ID and connection string. The Users table will hold the username, password, and a FK to the Tenant ID.
You login against the central DB (which is always a static connection string). After you can join your tables and have a connection string for the master account.
Upvotes: 0