-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DbContext.ChangeTracker.HasChanges() not working as expected #14808
Comments
Note for triage: I was able to reproduce this. |
@AndriySvyryd The issue here is that we create a special additional entry to handle owned type replacement--this is the state manager contents when HasChanges is called:
So it's clear why HasChanges returns true. But if HasChanges is intended to indicate whether or not changes need to be made to the database, then this is wrong. On the other hand, if HasChanges is intended to only indicate that there might be changes made to the database, then this is okay. Although HasChanges is then less useful. Thoughts? |
The way it's described I think it should return false. If you want to detect this case you'd need to use different API. |
But perhaps the way to fix this is that setting the state to unchanged should detach the deleted shared entry and copy over the original values. |
We are not able to find any Added/Updated/Deleted entities from
ChangeTracker.Entries()
, butChangeTracker.HasChanges()
shows TRUESteps to reproduce
Further technical details
EF Core version: 2.2.2
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 Pro 1809
IDE: Visual Studio 2017 15.9.7
The text was updated successfully, but these errors were encountered: