Why does the DBContext Find method have to check the cache to detect changes that are still waiting to be committed to the database?

Bindings to this method [DBContext.Find] will by default trigger an object cache check to detect changes that are still expected to commit the database

Performance Recommendations for Entity Framework 5

I don’t understand at all: why should the Find method detect changes that are not tied to the database? Why can this be useful for this? What is the reason this method checks the cache for these changes?

The Find method returns a cached copy of the object, regardless of whether it is stored in the database or not. If this object does not exist in the cache, then the Find method queries the database, receives this object and attaches it to the cache, and then returns it to the caller. Why is it necessary to determine whether an object is already attached to the database or is still not?

Please explain this to beginners!

PS Excuse me, my English, this is not my native language!

Upd. Find DetectChanges . AutoDetectChangesEnabled = false, DetectChanges . ( ) , AutoDetectChangesEnabled ? Add, : http://ilmatte.wordpress.com/2013/01/01/entity-framework-code-first-always-disable-autodetectchanges-when-importing-data/, , ?

+4

All Articles