1

I have two tables without any cascade deleting, the two tables have 1 to many relation ship.

When loading the entities that map that tables , and try to delete the parent entity then 2 scenarios will execute:

  1. The entity framework will force the cascade delete when both entities were loaded.
  2. If the child entity was not loaded it will raise an exception

How to guarantee that the entity framework will execute the second scenario always???? What I mean, I need to raise an exception without force delete cascade behavior.

thank you so much.

Slauma
  • 175,098
  • 59
  • 401
  • 420
alaa farah
  • 11
  • 1
  • Good question! I other words: You want to delete the children *only* if you explicitely call `DeleteObject` for each child, right? – Slauma Oct 10 '11 at 18:46
  • 1
    Check your properties of association between those entities in EDMX. The first normally doesn't happen - you must instruct EF to do that and one place where this can be done is in properties of association where cascade delete can be enforced. Also make sure that you are not using [identifying association](http://stackoverflow.com/questions/4922228/entity-framework-4-delete-object-from-entity-collection/4925040#4925040). – Ladislav Mrnka Oct 11 '11 at 08:02

0 Answers0