We are developing a multi-tenant application using NHibernate where all tenants share the same database.
One option we considered was to use a tenant specific prefix for our database objects (I believe this the same approach taken by Orchard).
This would at least give us some kind of recovery model for tenant data and would mean we wouldn't have to include a tenantid filter on most of our queries.
So my question - has anyone employed this strategy? If so, how did you go about it.
Specifically, can we use the same SessionFactory for all tenants and can we use NHibernate to generate a new set of tables for a "new" tenant at runtime (is it safe to do so).
Thanks Ben
[Update]
This was a worthwhile investigation but ultimately we decided that a shared schema was more suitable for our needs. Schema per tenant clearly offers better separation of tenant data but makes maintenance more difficult. Since our tenants are only storing small amounts of data, the thought of having 10 tables * 1K tenants is a little off-putting.