Multitenant NHibernate application with a separate SQL Server schema for each tenant

I am writing a new multi-user WCF RIA application. I plan to have a common database with a separate SQL Server schema for each tenant. I would like to use NHibernate for object-rational mapping.

The configuration of the SQL Server schema in the mapping classes does not help, because it is static and each tenant will need one set of mapping classes.

Is it possible to dynamically configure ISession, which SQL Server schema should be used to map objects to tables?

+4
source share
2 answers

You will need to create a separate SessionFactory for each client by changing the default_schema property in the configuration accordingly.

+3
source

If there is no connection between clients, it may make sense to have separate databases.

Last but not least, if client A says β€œplease restore,” you will not destroy other client data.

+1
source

Source: https://habr.com/ru/post/1333880/


All Articles