simendsjo
simendsjo

Reputation: 4749

Mapping nhibernate to several databases that share schema but not data

I have multiple databases that should all be active at the same time. They share schema, but not the data.

AFAIK nhibernate use the class type to know what mapping and database it is connected to, right? So once it gets an object, it wouldn't know if it belongs to database a or b.

I think it's possible to solve this using inheritance, but it's a real pain as there are in around 10 different databases...

Any ideas how this might be solved using nhibernate (burrow)?

I found this, but it's not the same as that is just choosing a single database out of many. I need to have them open at the same time using distinct data.

I also looked at NHibernate.Shards, but that wont work either. This is legacy databases that cannot change.

Upvotes: 0

Views: 168

Answers (1)

Kris Watkins
Kris Watkins

Reputation: 1

If the mappings are the same for each of your databases I think that I would have an ISessionFactory instance per database, mapped using the same mappings, then you would get an ISession from the appropriate one to access the particular database

Upvotes: 0

Related Questions