-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Refactor InternalEntityEntry in preparation for complex collection support #36165
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
Conversation
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.
Pull Request Overview
This PR refactors the internal change-tracking infrastructure to prepare for complex collection support by extracting InternalEntryBase, removing IInternalEntry.Object, and moving common change-tracking code to TypeBase.
- Updates method signatures and parameter types to use IInternalEntry for better abstraction.
- Introduces new state management via InternalEntryBase.StateData and adjusts snapshot and relationship handling.
- Adjusts EF Core scaffolding and collection entry code to support complex types and collections.
Reviewed Changes
Copilot reviewed 208 out of 208 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/EFCore/ChangeTracking/Internal/ShadowValuesFactoryFactory.cs | Adjusts GetPropertyCount signature and uses new indexer syntax for shadow values. |
src/EFCore/ChangeTracking/Internal/RelationshipSnapshotFactoryFactory.cs | Changes GetPropertyCount signature and safely casts structuralType where necessary. |
src/EFCore/ChangeTracking/Internal/OriginalValuesFactoryFactory.cs | Updates GetPropertyCount to use structuralType.Counts.OriginalValueCount. |
src/EFCore/ChangeTracking/Internal/InternalEntryBase.StateData.cs | New file adding bit-level state management and property flag handling. |
src/EFCore/ChangeTracking/Internal/InternalEntryBase.SidecarValues.cs | Updates signature by renaming to InternalEntryBase. |
src/EFCore/ChangeTracking/Internal/InternalEntryBase.OriginalValues.cs | Updates parameter types to use InternalEntryBase and revised OriginalValues factory. |
src/EFCore/ChangeTracking/Internal/InternalEntityEntryNotifier.cs | Changes method signatures to use IInternalEntry. |
src/EFCore/ChangeTracking/Internal/IInternalEntry.cs | Removes IInternalEntry.Object and adds properties/methods to support the new design. |
src/EFCore/ChangeTracking/Internal/IChangeDetector.cs | Updates change notification methods to use IInternalEntry. |
src/EFCore/ChangeTracking/Internal/EmptyShadowValuesFactoryFactory.cs | Signature updates for GetPropertyCount consistent with new types. |
src/EFCore/ChangeTracking/Internal/ChangeDetector.cs | Updates change detection logic and method signatures to use IInternalEntry with necessary casts. |
src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs | Uses new collection expression syntax for initializing properties. |
src/EFCore/ChangeTracking/ComplexPropertyEntry`.cs | Updates constructor parameter from InternalEntityEntry to IInternalEntry and property access. |
src/EFCore/ChangeTracking/ComplexPropertyEntry.cs | Similar constructor and IsModified changes for complex properties. |
src/EFCore/ChangeTracking/CollectionEntry`.cs | Adjusts property access and collection query logic to use InternalEntityEntry consistently. |
src/EFCore/ChangeTracking/CollectionEntry.cs | Updates collection entry code to work with the refactored change-tracking types. |
src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs | Introduces support for complex collections and updates generated counts accordingly. |
Comments suppressed due to low confidence (3)
src/EFCore/ChangeTracking/ComplexPropertyEntry`.cs:34
- The file name contains an unexpected backtick (`). Consider renaming the file to remove the backtick for consistency.
public ComplexPropertyEntry(IInternalEntry internalEntry, IComplexProperty complexProperty)
src/EFCore/ChangeTracking/CollectionEntry`.cs:62
- The file name includes an extraneous backtick (`); consider renaming the file to remove it for consistency with project naming conventions.
=> new(InternalEntityEntry);
src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs:111
- The use of the collection expression syntax initializes _properties as an array rather than a List as before. Verify that downstream code expecting a List is updated or that the array behavior is acceptable.
=> _properties ??= [.. EntityType.GetFlattenedProperties()];
24e1985
to
61659f2
Compare
0d8b2df
to
b7234f9
Compare
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.
🐑 🇮🇹 looks legit :)
@@ -1219,7 +1324,7 @@ public virtual ChangeTrackingStrategy GetChangeTrackingStrategy() | |||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | |||
/// </summary> | |||
public static string? CheckChangeTrackingStrategy( | |||
IReadOnlyTypeBase typeBase, | |||
IReadOnlyTypeBase structuralType, |
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.
We discussed this in the past, but should we consider renaming ITypeBase IStructuralType? While technically a breaking change, it's very unlikely anyone actually uses this... We could still keep ITypeBase as an obsolete super-interface of IStructuralType to get people some time etc.
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.
I don't think it's worth it yet. Will reconsider when we have another thing that implements it
e826135
to
579bb61
Compare
579bb61
to
24e3747
Compare
Extract
InternalEntryBase
Remove
IInternalEntry.Object
Move common change-tracking code to
TypeBase
Fix some minor model building issues related to complex types
Part of #31237