A referential integrity constraint violation occurred

前端 未结 6 1231
有刺的猬
有刺的猬 2021-01-18 04:54

I\'m trying to update an existing entity.

I have the following code:

public MamConfiguration_V1 Save(MamConfiguration_V1 item)
{
    mMaMDBEntities.M         


        
6条回答
  •  情歌与酒
    2021-01-18 05:59

    Seems like you have some relationship with foreign key field and a navigation property in the item, and those fields have conflicting values. This occurs when you load an entity and its related entities, change the relationship at one end, mark only that end as Modified and attempt to save. Make sure you modify relationship at both ends and mark all the affected entities as Modified before calling SaveChanges.

提交回复
热议问题