I am trying to delete a row from the database which has a split table assoicated with it, however, I cannot seem to delete the split table relationship.
Here is the code I am trying to execute
public void DeleteProductItemSplit(ProductItem pi)
{
// ProductItemData is the split table
var data = new ProductItemData() { Id = pi.Id };
m_Context.ProductItemData.Attach(data);
m_Context.ProductItemData.Remove(data);
}
On the second line
m_Context.ProductItemData.Attach(data);
I get this error
Additional information: Multiplicity constraint violated. The role 'ProductItem_Data_Target' of the relationship 'UpdaterDataLayer.ProductItem_Data' has multiplicity 1 or 0..1.
If I ignore the attach line, then I get this error when trying to remove the object
The object cannot be deleted because it was not found in the ObjectStateManager.
Any ideas on how to solve?
Thanks