Multitenant NHibernate application with with separate SQL Server schema for each tenant
I am w开发者_JS百科riting a new multi-tenant WCF RIA application. I plan to have a shared database with separate SQL Server schema for each tenant. I would like to use NHibernate for object-ralational mapping.
Configuration of SQL Server schema in mapping classes doesn't help because it is static and would need one set of mapping classes for each tenant.
Is it possible to dynamically configure ISession which SQL Server schema should be used for mapping objects to tables?
You'll have to create a separate SessionFactory for each client, changing the default_schema
property in the configuration accordingly.
If there is no link between clients, then it maybe makes sense to have separate databases.
Not least, if client A says "please restore" you won't destroy other client's data.
精彩评论