efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Support for ExecuteUpdate/Delete which spans multiple tables (TPT, TPC...)

Open smitpatel opened this issue 3 years ago • 3 comments

  • TPT
  • Entity splitting
  • TPC (when the delete is not based on key)

We can support via multiple commands in same batch. Could be complicated to figure out the rows affect count depending on the meaning of it. Delete is somewhat easier but Update could be tricky as we need to figure out which property set goes where.

smitpatel avatar Jul 26 '22 17:07 smitpatel

Also keep in mind that if we start sending multiple commands then we need to add transaction around it.

smitpatel avatar Jul 29 '22 17:07 smitpatel

Just came across this today where we have a table mapped to two different entities (for lighter data retrieval when the full object is not necessary but don't want an anonymous type).

The library here https://github.com/borisdj/EFCore.BulkExtensions still works but Batch Deleting / Updating has been obsoleted in favour of using EF methods.

Is there any plan to fix the implementation for table splitting?

kev24uk avatar Feb 16 '24 15:02 kev24uk

@kev24uk this issue for tracking having a single ExecuteUpdate/Delete touch multiple tables (e.g. because of inheritance), which doesn't sound like what you're looking for.

In 8.0 we've done some improvements to this area - see these notes in the What's New docs. If your scenario still doesn't work in 8.0, can you please open an issue with a minimal, runnable code sample that shows the problem?

roji avatar Feb 17 '24 08:02 roji