You are here: Home / Blog / posts / Programming Magic / A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance

A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance

by jsylvest — published Feb 14, 2011 10:50 AM, last modified Jan 28, 2014 11:54 AM
This exception "A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance" happens when:

Ok, this exception "A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance" can happen with NHibernate if you have an entity with a list of other entities with the .Cascade.AllDeleteOrphan() mapping.

If you clear the list by assigning it a new List<entity>(), this exception will appear.

Instead clear the list by using the .Clear() method.

When:

Where:

Contact