Exclude specific property from change tracking

Open
#19,461 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
database

Research direction

Start by examining EF Core's change-tracking behavior for geometry properties and how Metadata.AfterSaveBehaviour interacts with it. Reproduce the reported SaveChanges delay and verify whether a property can be excluded from standard tracking while still being manually marked modified with IsModified. Done means the requested behavior is clearly supported or the limitation is documented.

Written by the indexing model from the issue text.

Description

area-change-tracking customer-reported needs-design

I have an entity with a geometry column which causes SaveChanges to take a long time (>1min) whenever the entities are tracked - presumably due to having to compare geometries to determine whether they have changed. Due to other areas of the project making use of lazy loading, I can't turn change tracking off globally and so I have to make sure to use AsNoTracking everywhere this particular entity type is used (including queries that Include them) which is proving a bit of a pain. I tried setting Metadata.AfterSaveBehaviour to PropertySaveBehaviour.Ignore but this seems to still attempt to track changes to the property even though it would then (I believe) ignore any changes it found.

Is there any way to exclude the particular property from change tracking? If AfterSaveBehaviour set to Ignore worked as one might expect this would be a start but ideally there should be some way of excluding the property in standard change tracking but still allow it to be manually mark as modified (using IsModified which I assume (although I haven't tested this) would still cause a property to be ignore when setting AfterSaveBehaviour).

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.