EntityFramework.Docs
EntityFramework.Docs copied to clipboard
Confusing description of Tracking queries
This is confusingly written. Does this mean to convey that a query will never return any entity that exists in the context in the Added state?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: f3ffc114-df51-0be7-8972-6fcead14e011
- Version Independent ID: 94c34571-7314-aab1-7898-93ac6d0f3430
- Content: Tracking vs. No-Tracking Queries - EF Core
- Content Source: entity-framework/core/querying/tracking.md
- Product: entity-framework
- Technology: entity-framework-core
- GitHub Login: @smitpatel
- Microsoft Alias: avickers
Yes - queries return entities from the database, so any entity instance not yet saved won't be returned.
Thanks Shay. Might I suggest rephrasing the documentation along these lines:
When the results are returned in a tracking query, EF Core will check if the entity is already in the context. If EF Core finds an existing entity, then the same instance is returned. EF Core won't overwrite current and original values of the entity's properties in the entry with the database values. If the entity isn't found in the context, then EF Core will create a new entity instance and attach it to the context. Queries only return entities that already exist the database. Any unsaved entities in the context will not be included in query results.