Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Is DetectChanges() needed in NorthwindDbContext? #173

Closed
matteocontrini opened this issue Oct 1, 2019 · 1 comment
Closed

Is DetectChanges() needed in NorthwindDbContext? #173

matteocontrini opened this issue Oct 1, 2019 · 1 comment

Comments

@matteocontrini
Copy link

Hi,
the AuditableEntity implementation is interesting, but I'm wondering if the call to ChangeTracker.DetectChanges(); is really needed.

https://github.com/JasonGT/NorthwindTraders/blob/2c0659e759c41b05719e174caa4836156ce74c9b/Src/Persistence/NorthwindDbContext.cs#L53-L55

According to the official docs, DetectChanges() is called automatically when going through the entries of the ChangeTracker:

DetectChanges() is usually called automatically by the context when up-to-date information is required (before SaveChanges() and when returning change tracking information)

@jasontaylordev
Copy link
Owner

Hi Matt - thanks for the feedback. You're right - detect changes was not required. In the above commit I've removed it and added some integration tests to verify the behaviour. Thanks! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants