NHibernate.LazyInitializationException: failed to lazily initialize a collection of role after calling TransactionManager.RequireNew()

Topics: General, Troubleshooting
Dec 10, 2015 at 9:39 PM
To improve performance for creating lots of content items in some custom modules I have called
in some 1.8.x sites after creation of every e. g. 100 content items and this worked good.

Im doing pretty much the same in a new 1.9.x site and after the RequireNew() is called subsequent calls to _contentManager.Create result in NHibernate.LazyInitializationException:

NHibernate.LazyInitializationException - (null) - Initializing[Orchard.ContentManagement.Records.ContentItemRecord#2913]-failed to lazily initialize a collection of role: Orchard.ContentManagement.Records.ContentItemRecord.Versions, no session or session was closed

Any idea what is going wrong and how I could solve this? Thanks.