I have the following classes in Entity Framework 4.1 (the classes have been pruned to keep the code readable)
public class MetaInformation
{
Cascade delete will not help you here. Cascade delete works only if you delete parent entity (MetaInformationObject
). The problem here is that calling Clear on the collection of related objects doesn't delete them. It only deletes the relation (= it will set foreign key in MetaInformation
to null) but it is not allowed by your mapping constraints (you defined relation as required). The ways to avoid this are either:
MetaInformation
s and delete each of themClear
will not only break the relation but mark related entity as deleted as well.