B
B
BloodyBlade2017-01-09 09:17:56
JavaScript
BloodyBlade, 2017-01-09 09:17:56

How to implement multi-tenant system on asp.net mvc?

Hello. In general, I faced the problem of implementing a multi-tenant cloud system. I want to share data at the database level (that is, each client has its own database), but I don’t quite understand how to implement this. Now I use the Entity Framework to access data, there is an idea to replace connectionString for different tenants, but maybe this is not quite the right line of thought?
And the second part of the question. I would like to organize access to data from different addresses, i.e. client1 has a site1.ru domain, client2 has a site2.ru domain, etc. Sites may differ from each other visually, but functionally they are all the same. Is it possible to implement such a scheme in asp.net mvc? And I want to add new clients without recompiling the entire system. I get a variant with areas, but then when adding a new client, I will have to recompile everything.
I would appreciate any information, thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Pavlov, 2017-01-19
@BloodyBlade

Move the logic to the API (WebAPI), access it from ASP.NET MVC applications that are hosted under different domains and with each API call, in addition to other parameters, they will pass two additional parameters - where the request comes from (to identify the domain) and who asks (to identify the user ).
The logic in the API based on domain and user will use the correct database accordingly. You can store the correspondence of the domain / user and its database in the service database. In the same place - to store user data and other general service information.
If the database structure for each user is the same, then the processing logic will be the same. When adding a new user, it will be enough to deploy a new ASP.NET MVC application to the domain, configure it to the API address, and enter the necessary data in the backend. If the base for each user is created automatically programmatically - that's it. If not, create another database.
Do you write CMS?

V
Vyacheslav Zolotov, 2017-01-09
@SZolotov

https://github.com/openiddict

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question