views:

233

answers:

1

I have a simple ASP.NET MVC + OpenID + NHibernate app (on top of MSSQL Server DB). The app is strictly single tenant and supports multiple users with only 2 roles (Admin and User).

I would like to convert this app into a multi-tenant app. My requirements are limited: I just need to introduce the notion of Accounts, each account having its own set of users and behaving exactly like the original non-multi-tenant app. There is no interactions between accounts.

What are the best practices to do this migration the most simple way? In particular, I am can manually update all entities and repositories with an *Account_id* field, and upload the logic too. But, I am wondering if there are no smarter approaches that would somehow abstract this aspect.

Ps: the app is very light, I do not wish to introduce a new DB instance for each account.

+2  A: 

Probably the best thing I could think of is to embrace the Filter feature of NHibernate. It allows you to easily enable a filter on the query you're running and you can optionally enable them on tables that are setup to be multi-tenanted

lomaxx