我在我的模型如何在实体框架中级联删除?
汽车和carPart
与1两个对象:N的关系。
我想删除级联实体车。 当我删除我得到以下异常:
The operation failed: The relationship could not be changed because one or
more of the foreign-key properties is non-nullable. When a change is made
to a relationship, the related foreign-key property is set to a null value.
If the foreign-key does not support null values, a new relationship must
be defined, the foreign-key property must be assigned another non-null value,
or the unrelated object must be deleted.
我认为它会尝试先删除该汽车对象中的汽车零部件。
由于外键,这是不可能的。
我该如何处理?
我想要的,显然是先删除carPart,然后再删除车。
谢谢。
感谢这个答案! –