-
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
Allow explicit temporary values that are stored in the entity instance #24245
Labels
area-change-tracking
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-enhancement
Milestone
Comments
ajcvickers
added
area-change-tracking
area-dbcontext
customer-reported
type-enhancement
and removed
area-dbcontext
labels
Feb 23, 2021
ajcvickers
added
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
and removed
consider-for-current-release
labels
Apr 7, 2021
This was referenced Apr 8, 2021
ajcvickers
added a commit
that referenced
this issue
Apr 19, 2021
@ajcvickers I tried 6.0.0-preview4, and see the same behaviour as posted above. Should I be doing something different? |
@Zero3 Please open a new issue and attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-change-tracking
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-enhancement
While an application is free to manipulate and set temporary values, those values will never be reflected in the entity instance since the current code requires a CLR default value in the entity instance before it will consider a value temporary. This makes it difficult to work with explicit temporary values outside the context of EF Core where the values need to be set into the entities even after EF Core is tracking them.
Originally reported by @Zero3 here: #12378 (comment)
I tried this, but as mentioned above, EF will then save the temporary value to database. And if one manually does
context.Entry(entity).Property(e => e.Id).IsTemporary = true;
, then EF resetsId
back to0
, and we are back where we started.Here is an example of a custom
.Add()
method that doesn't work because of this behaviour:Output:
The text was updated successfully, but these errors were encountered: