# Transactional Session with NHibernate Persistence In order to use the [transactional session feature](/nservicebus/transactional-session/index.md) with NHibernate Persistence, add a reference to the `NServiceBus.NHibernate.TransactionalSession` NuGet package. ## Configuration To enable the transactional session feature: ```cs var persistence = config.UsePersistence(); persistence.EnableTransactionalSession(); ``` ## Opening a session To open a NHibernate transactional session: ```cs using var childScope = serviceProvider.CreateScope(); var session = childScope.ServiceProvider.GetService(); await session.Open(); // use the session await session.Commit(); ``` ## Transaction usage Message and database operations made via the transactional session are committed together once the session is committed: ```cs await session.Open(); // add messages to the transaction: await session.Send(new MyMessage()); // access the database: var nhibernateSession = session.SynchronizedStorageSession.Session(); await session.Commit(); ``` See the [NHibernate shared session documentation](/persistence/nhibernate/accessing-data.md) for further details about using the transaction. > [!WARNING] > In order to guarantee atomic consistency across message and database operations, the [outbox](/nservicebus/outbox/index.md) must be enabled. Otherwise `Commit` executes database modifications first and then messages are dispatched with best-effort.