0

I have a theoretical issue here. I've learnt that DbContextConfiguration.AutoDetectChangesEnabled property value determines whether the automatic detection of changes in the context is enabled. But, I've set it to false and the context still persists changes even when I don't call DbChangeTracker.DetectChanges manually.

Note: the only case when it doesn't persist is when I make changes to ICollection property of an entity (but it still persists when I change a navigation property i.e.: myEntity.OtherEntity = myOtherEntity).

So, I'd like to know what I've learnt wrong :)

Thanks a lot.

Giorgi

pangular
  • 699
  • 7
  • 27
  • 1
    Would you mind showing the code that has the unexpected behaviour? `AutoDetectChangesEnabled = false` should suppress saving changed, so there's probably some twist in your code that causes `DetectChanges` to fire anyhow. – Gert Arnold Jan 11 '13 at 10:47
  • Yep, there was a twist, it was - I manually set state of an entity to EntityState.Modified. Thanks. – pangular Jan 21 '13 at 10:56

1 Answers1

0

It happened because I manually set entity's state to Modified. This made the context save the changes for primitive and navigation properties but apparently wasn't enough for updating the collection property. Problem is solved.

pangular
  • 699
  • 7
  • 27