EF 4: Removing child object from collection does not delete it - why?

前端 未结 5 1334
执念已碎
执念已碎 2020-11-29 09:02

I use Entity Framework 4 and I have parent - child relation with \"Cascade Delete\" set. So i would expect when i remove a child from the parent that the child is deleted wh

5条回答
  •  有刺的猬
    2020-11-29 09:41

    You aren't deleting the object with the remove statement. Instead you are attempting to alter a record and make it an orphan (by setting the foreign key to null). The database has a non-null constraint on that column and prevents you from doing so.

提交回复
热议问题