title: nhibernate mapping: A collection with cascade="all-delete-orphan" was no longer referenced
body: <p>I am having some probs with my fluent mappings. I have an entity with a child collection of entities i.e Event and EventItems for example.</p>
  
  <p>If I set my cascade mapping of the collection to AllDeleteOrphan I get the following error when saving a new entity to the DB:
  NHibernate.HibernateException : A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: Core.Event.EventItems</p>
  
  <p>If I set the cascade to All it works fine? Below are my classes and mapping files:</p>
  
  <pre><code> public class EventMap : ClassMap&lt;Event&gt;
  {
      public EventMap()
      {
          Id(x =&gt; x.Id, "Id")
              .UnsavedValue("00000000-0000-0000-0000-000000000000")
              .GeneratedBy.GuidComb();
  
          Map(x =&gt; x.Name);
          HasMany(x =&gt; x.EventItems)
              .Inverse()
              .KeyColumn("EventId")
              .AsBag()
              .Cascade.AllDeleteOrphan();
      }
  }
  
    public class EventItemMap : SubclassMap&lt;EventItem&gt;
  {
      public EventItemMap()
      {
           Id(x =&gt; x.Id, "Id")
              .UnsavedValue("00000000-0000-0000-0000-000000000000")
              .GeneratedBy.GuidComb();
          References(x =&gt; x.Event, "EventId");
      }
  }
  
  
  
  public class Event : EntityBase
  {
      private IList&lt;EventItem&gt; _EventItems;
  
      protected Event()
      {
          InitMembers();
      }
  
      public Event(string name)
          : this()
      {
          Name = name;
      }
  
      private void InitMembers()
      {
          _EventItems = new List&lt;EventItem&gt;();
      }
  
      public virtual EventItem CreateEventItem(string name)
      {
          EventItem eventItem = new EventItem(this, name);
          _EventItems.Add(eventItem);
          return eventItem;
      }
  
      public virtual string Name { get; private set; }
      public virtual IList&lt;EventItem&gt; EventItems
      {
          get
          {
              return _EventItems.ToList&lt;EventItem&gt;().AsReadOnly();
          }
          protected set
          {
              _EventItems = value;
          }
      }
  }
  
      public class EventItem : EntityBase
  {
      protected EventItem()
      {
      }
  
      public EventItem(Event @event, string name):base(name)
      {
          Event = @event;
      }
  
      public virtual Event Event { get; private set; }
  }
  </code></pre>
  
  <p>Pretty stumped here. Any tips greatly appreciated.</p>
  
  <p>Chev</p>