I load a Contact-objekt from the database. The Object Contact has a one-to-many mapping to ContactSecurity:
<set name="ContactSecuritys" lazy="true" inverse="true" cascade="none" >
<key>
<column name="ContactId"/>
</key>
<one-to-many class="ContactSecurity"/>
</set>
Now, I try to do:
contact.ContactSecuritys.Add(new ContactSecurity(Guid.NewGuid()));
Session.Merge(contact);
But this is throwing an TransientObjectExcpeption 'object is an unsaved transient instance - save the transient instance before merging: Prayon.Entities.ContactSecurity'
I have also tried
contact.ContactSecuritys.Add(new ContactSecurity(Guid.NewGuid()) {Contact = contact});
Session.Merge(contact);
What I am doing wrong? - Does I have to extra-save the new ContactSecurity-Object with referenced Contact before merging the contact? - Or is there a simpler way to do this?
Thanks for any help.