k.c.
k.c.

Reputation: 1835

NHibernate Webapp With Multiple Databases Which SessionContext To Use

We use NHibernate with fluent configuration in our web application.

We have a single configuration database and a multitude of different databases holding customer data.

For each database we make a fluent configuration and a SessionFactory when it is first used.

We obtain sessions by calling the OpenSession method on it, and dispose it when we are through with it.

However sometimes we get an error message that the ADO data-reader is still active when we attempt to read. Indicating that NHibernate is trying to (re)use the same connection, something we are trying to avoid.

How can we make sure that our database requests are handled by a connection in an atomic fashion. (No re-use by other requests)

I guess that recreating the SessionFactory might work, but that seems expensive

Upvotes: 0

Views: 268

Answers (1)

jakobandersen
jakobandersen

Reputation: 1409

A few questions

  • You are using different connection strings so it is separate application pools?
  • What is the exact error message you get?

I can't see how this should be nHibernate's fault. If the problem is easily reproduceable then maybe you can try to:

  • Trace from the database side to see whats going on (especially sp_resetconnection)
  • Disable connection pooling to see if that makes a difference

Upvotes: 2

Related Questions