I'm getting the following error on our production web server:
NHibernate.LazyInitializationException
:
Initializing[Domain.Entities.AudienceTypes.Region#4]-failed to lazily initialize a
collection of role: Domain.Entities.AudienceTypes.Region.PeerGroups,
no session or session was closed
which isn't good. The only way to get the application working again is to reset IIS, which isn't really an option. What does this mean? How can I prevent it?
To avoid this issue you need to change reference for PeerGroups in your Region mapping class as below
References(x => x.PeerGroupId, "PeerGroupId").Fetch.Join();
Adding Fetch.Join() will prevent LazyInitializationException.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With