0

Would either nhibernate or entity-framework be able to support 1000's of databases?

Scenerio: This would be a Saas application, *where each client gets their own seperate databas*e. So 10K clients, would mean 10K databases (their domain would map the to a specific db).

Could nhibernate support such a design requirement?

How about entity-framework?

I would imagine the connection string would be modified during the begin_request for that specific customer, based on their own domain name which would map them to their specific db.

Note Please don't tell me this is a poor design choice, just take it as a requirement.

Supporting mysql would also be an added benefit, which I know nhibernate does but not sure about EF

codecompleting
  • 9,251
  • 13
  • 61
  • 102
  • Might want to look at RavenDB as it supports the direct concepts of tenant databases as you described. I'm not sure off hand what happens when you would get into the tens of thousands of tenants. I would assume all would work well as long as the database has the right resources to serve the level of concurrency load for it. – Chris Marisic Sep 13 '11 at 19:50
  • nah I wouldn't want to use ravendb for something like this, tried and true is the way to go. – codecompleting Sep 13 '11 at 20:07
  • If you consider each database in MySQL as a "schema", you might be able to pull it of with a single connection. If the requirement isn't based on "different credentials" it might work. Switching connection strings at runtime won't fly though, because then you will end up with a stale cache (unless you want to disable all form of caching) – jishi Sep 14 '11 at 13:57
  • connection pooling I think will also pose an issue, since each unique connection string results in its own pool. – codecompleting Sep 15 '11 at 16:18

1 Answers1

0

NHibernate can handle this, you'll need a session factory for each database.

Every session factory would have a different name/id, everytime you connect to a database, you should get the nHibernate session from the right session factory.

Also, build session factories is an expensive process, so you should cache them. SharpArch can help you with multiples session factories and cached session factories.

Rafael Mueller
  • 6,028
  • 3
  • 24
  • 28
  • 1
    I think the memory footprint would grow to be unbearable with a few hundred databases. I think each session factory would use approx 20-30 MB, and that would be several gigabytes then. – jishi Sep 14 '11 at 13:54