I have the follow many-to-many relation:
Class ContactGrup : Contact
{
[Field(LazyLoad = true)]
[Association(OnOwnerRemove = OnRemoveAction.Clear,
OnTargetRemove =OnRemoveAction.Clear)]
public EntitySet<Contact> Z_ContactGroupContactList { get; set; }
}
Class Contact
{
[Field(LazyLoad = true)]
[Association(OnOwnerRemove = OnRemoveAction.Clear,
OnTargetRemove = OnRemoveAction.Clear, PairTo = "Z_ContactGroupContactList")]
public EntitySet<ContactGroup> Z_ContactGroupList { get; set; }
}
DataObjects creates an association table with the follow name:
"ContactGroup-Z_ContactGroupContactList-Contact"
Contact contact= Contact.Load(1);
Contact refContact = (Contact)contact.ContactGroupList[0];
cotact.Remove();
refContact.Remove();
m_Session.DisconnectedState.ApplyChanges();
But during the save the SQL server reports the follow error message:
Die DELETE-Anweisung steht in Konflikt mit der REFERENCE-Einschränkung 'FK_ContactGroup-Z_ContactGroupContactList-Contact_Master'.
Der Konflikt trat in der 'KLIBNET2_V10'-Datenbank,Tabelle 'dbo.ContactGroup-Z_ContactGroupContactList-Contact', column 'ContactGroup' auf.
Die DELETE-Anweisung steht in Konflikt mit der REFERENCE-Einschränkung 'FK_ContactGroup_Contact'. Der Konflikt trat in der 'KLIBNET2_V10'-Datenbank, Tabelle 'dbo.ContactGroup', column 'Id' auf.
The message is in german: He meens that the contact and refContact can not be deleted because he is referenced in the association table.
Is my implementation of the many-to-many relation right?
Maybe the problem is on the OnTargetRemove or on the OnOwnerRemove?
Regards Marco Leonardi
asked
Sep 06 '10 at 11:20
MarcoLeonardi
10●5●5●7
Which line leads to an error? A line with
m_Session.DisconnectedState.ApplyChanges
?Yes exactly.
Could you send us the log produced by DataObjects.Net on this operation?
Btw, the code is fully correct.
But I know you intensively use events for BLL, so I'd like to check if it could be a side effect of this.