6

When context contains related entitties and SaveChanges is called EF issues queries in right sequence not breaking referential constrainst.

Unfortuantely, EF does not support alternative keys, hence it cannot deduce the correct order of commands, so we need to define the order ourselves if this is possible.

Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137

1 Answers1

5

I think the order of operation is totally under entity framework control - essentially meaning you cannot influence the order of operation.

I think the only way to manage this is to make the changes in order saving changes at each point you want it to commit - i.e. force EF to make the changes in order.

Similar question: https://stackoverflow.com/a/7335895/626354

Community
  • 1
  • 1
Matt Whetton
  • 6,616
  • 5
  • 36
  • 57