-
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
Fix ValueGenerated On Add Or Update, , make ValueGeneratedOnUpdate() and ValueGeneratedOnAddOrUpdate() working #26713
Conversation
@ajcvickers @AndriySvyryd efcore/test/EFCore.Cosmos.FunctionalTests/Internal/IdentifierShadowValuePresenceTest.cs Lines 35 to 57 in 50f8b84
Related issues and pull requests |
…te action in RelationalDB provider and None-RelationalDB provider, so each provider can has it's owe logic to use ValueGenerator for Generate values. Like RelationalDB,the HasDefaultValueSql() and HasDefaultValue AnnotationNames means property has default value, different from None-RelationalDB.
if (attachFirst) | ||
{ | ||
context.Entry(gu1).State = EntityState.Unchanged; | ||
Assert.NotEqual(default, gu1.Id); | ||
Assert.Equal(EntityState.Unchanged, context.Entry(gu1).State); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong formatting
[DatabaseGenerated(DatabaseGeneratedOption.None)] | ||
public int Id | ||
{ | ||
get => _id; | ||
set => SetWithNotify(value, ref _id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong formatting
@@ -1883,7 +1915,7 @@ public EntityEntry ToEntityEntry() | |||
break; | |||
case NotifyCollectionChangedAction.Reset: | |||
throw new InvalidOperationException(CoreStrings.ResetNotSupported); | |||
// Note: ignoring Move since index not important | |||
// Note: ignoring Move since index not important |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Saibamen Not sure,but this src file auto-format by vs after last marge
As @AndriySvyryd mentioned above, making this kind of change is dangerous without more generally updating the handling of modified key properties, as tracked by #4073 and #19135, and possibly other issues. This kind of change would also need significant new testing to make sure it does not result in bad state that cannot be handled by other parts of the stack. For these reasons, this is not a change we plan to merge. |
Fixes #6999 and #19765
docs #3165
When useing ValueGeneratedOnUpdate(), set PropertyBuilder.Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Save) for update.
When useing ValueGeneratedOnAddOrUpdate(), set PropertyBuilder.Metadata.SetBeforeSaveBehavior(PropertySaveBehavior.Save) for add and PropertyBuilder.Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Save) for update.