-
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
Changes to entities ignored while looping through change tracker entries #17997
Comments
Wait for @ajcvickers |
Verified that this reproduce in 3.0 |
I stumbled across this too while testing out EF 3.0 RC and release, it was causing weird things to happen in some spots. I was too focused on other things to report it, but its definitely going to make our codebase stay on 2.6 for a while longer. I hope this can gets fixed soon. |
It seems this is planned to be fixed in 3.1.0. Is there perhaps any known workaround we can use in the meantime? Else we will have to wait till November until we can upgrade to ASP.NET Core 3.x. |
Fixes #17997 The problem here was that the temporary values snapshot was copying current values rather than starting with empty values. This then meant that when the current value was set to null, the temp value took over, which was then incorrect. Related to this, when setting a current value to null, the temp value (if it exists) must also be set to null otherwise it will start being used.
@nphmuller Based on the root cause, workarounds might be:
|
Fixes #17997 The problem here was that the temporary values snapshot was copying current values rather than starting with empty values. This then meant that when the current value was set to null, the temp value took over, which was then incorrect. Related to this, when setting a current value to null, the temp value (if it exists) must also be set to null otherwise it will start being used.
Fixes #17997 The problem here was that the temporary values snapshot was copying current values rather than starting with empty values. This then meant that when the current value was set to null, the temp value took over, which was then incorrect. Related to this, when setting a current value to null, the temp value (if it exists) must also be set to null otherwise it will start being used.
Fixes #17997 The problem here was that the temporary values snapshot was copying current values rather than starting with empty values. This then meant that when the current value was set to null, the temp value took over, which was then incorrect. Related to this, when setting a current value to null, the temp value (if it exists) must also be set to null otherwise it will start being used.
@ajcvickers Finally Something Crunchy? 😄 |
Since 3.1 will mainly contain bug fixes I think it’s worth trying out the nightlies. |
@dragnilar @nphmuller Always the nightlies, otherwise we won't have enough time to respond if you find issues. |
I have some code that I run just before SaveChanges is called. This code loops through the entries currently in the change tracker and changes a few values of the underlying entities.
During upgrade to
3.0.0-rc1.19456.14
I noticed that these changes are now ignored. I've also verified this in3.0.0-rc2.19463.9
where this still happens. Edit: Also still happens on 3.0.0. (Congratulations on the release, btw! 😄)This happens with the SqlServer provider, and it doesn't happen with the InMemory provider.
Steps to reproduce
The following code ran in 2.2.x, because the foreign key was set to
null
while looping the entries. Now, because this change is ignored, it throws because an entity with the foreign key999
doesn't exist.Further technical details
EF Core version:
3.0.0-rc1.19456.14
/3.0.0-rc2.19463.9
/3.0.0
Database provider:
SqlServer
Target framework:
netcoreapp3.0
Operating system:
Win 10 1903
IDE:
Visual Studio 2019 16.3.0
The text was updated successfully, but these errors were encountered: