1

I have a base class A and a derived class B. Using TPT, the ON CASCADE DELETE does not get set on the relationship between B.id and A.id so I cannot delete A without deleting B first.

The problem is, A has a many to one relationship with another entity which sits at the root of the graph, let's call it R.

R is set to cascade deletes to all its A children. This half-works; deleting R causes a delete on A but because EF didn't set a cascade down to table B, it falls over.

Is this a feature?

Luke Puplett
  • 42,091
  • 47
  • 181
  • 266
  • For me it sounds more like a bug. – Ladislav Mrnka Jul 02 '12 at 20:21
  • 1
    For me too: http://stackoverflow.com/questions/9064273/cascade-delete-in-entity-framework-table-per-type-inheritance and http://stackoverflow.com/questions/8599617/problems-using-tpt-table-per-type-in-ef-4-2-and-deletion-of-parent-objects – Slauma Jul 02 '12 at 20:24
  • Thanks guys, +1 for Slauma on the links. I'll try switching to using filter mappings and TPH (page 391 in Programming Entity Framework, J Lerman) otherwise I'll remove inheritence altogether. – Luke Puplett Jul 03 '12 at 08:58
  • I'll leave the question unanswered in case someone from the EF team has something to say, otherwise, using TPH DDL generation solved it. Using mappings as per page 391 doesn't work when working Model 1st. – Luke Puplett Jul 03 '12 at 14:04

0 Answers0