![]() ![]() If you don't need to update the entities retrieved from the database, then a no-tracking query should be used. They're quicker to execute because there's no need to set up the change tracking information. No tracking queries are useful when the results are used in a read-only scenario. Query results don't contain any entity which is added to the context but not yet saved to the database. If the entity isn't found in the context, then EF Core will create a new entity instance and attach it to the context. EF Core won't overwrite current and original values of the entity's properties in the entry with the database values. If EF Core finds an existing entity, then the same instance is returned. When the results are returned in a tracking query, EF Core will check if the entity is already in the context. ![]() In the following example, the change to the blogs rating will be detected and persisted to the database during SaveChanges(). Which means you can make changes to those entity instances and have those changes persisted by SaveChanges(). ![]() Tracking queriesīy default, queries that return entity types are tracking. You can view this article's sample on GitHub. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |