-
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
A BUG in EntityFramewrokCore about ValueGenerateOnAdd() and ValueGenerateOnAddOrUpdate() #16434
Comments
@ym9288 Please post a small, runnable project/solution or complete code listing that demonstrates the behavior you are seeing so that we can investigate. |
@ym9288 The call to Note fore triage: this is somewhat confusing behavior, but changing it risks not saving modified value if they need to be saved. We should see if we can make the experience better. |
@ajcvickers My meaning : |
@ym9288 Sorry, my previous analysis was not correct. I didn't that the configuration for
Note that After this change, running your code, inserting the entity uses the following SQL: SET NOCOUNT ON;
INSERT INTO [PatientInfo] ([address], [age], [ageStr], [patientName], [phone], [sex])
VALUES (@p0, @p1, @p2, @p3, @p4, @p5);
SELECT [patientId], [createTime], [updateTime]
FROM [PatientInfo]
WHERE @@ROWCOUNT = 1 AND [patientId] = scope_identity(); As you cane see, the values for The generated SQL for the update is: SET NOCOUNT ON;
UPDATE [PatientInfo] SET [address] = @p0, [age] = @p1, [patientName] = @p2, [phone] = @p3, [sex] = @p4
WHERE [patientId] = @p5;
SELECT [updateTime]
FROM [PatientInfo]
WHERE @@ROWCOUNT = 1 AND [patientId] = @p5; |
Triage: added a note to #14532 to consider this scenario. |
Submitted to site feedback by @ym9288
There are my 2 Properties Sets of my Entity:
they "createTime" use ValueGeneratedOnAdd and "updateTime" use ValueGeneratedOnAddOrUpdate
It looks like that whenever my Update on my entity should make the "updateTime" be Updated!,and "createTime" should never be updated when I update my entity.
But,when I update my entity,I got the SQL generated by EFCore:
EFCore updated the "createTime" column,otherwise,did not update "updateTime" column,
At this time,I changed the "createTime" column's Property Set to use ValueGeneratedOnAddOrUpdate(),
and changed the "updateTime" column's Property to use ValueGenerateOnAdd().
with the same opertion of just now(tips:update entity),
here is the SQL
You see,"updateTime" was seted but no "createTime".
over... here is my contact,you can ask me some questions.
QQ/Email:280823786@qq.com,
The text was updated successfully, but these errors were encountered: