Skip to content

Improve entity history handling for shared types and JSON#24519

Merged
maliming merged 7 commits intodevfrom
salihozkara/improve-entity-changes
Dec 31, 2025
Merged

Improve entity history handling for shared types and JSON#24519
maliming merged 7 commits intodevfrom
salihozkara/improve-entity-changes

Conversation

@salihozkara
Copy link
Member

Enhanced EntityHistoryHelper to correctly handle entities with shared CLR types and properties mapped to JSON. Added logic to determine property type from entry values when the type is object, and improved property change tracking for JSON-mapped navigation properties.

Enhanced EntityHistoryHelper to correctly handle entities with shared CLR types and properties mapped to JSON. Added logic to determine property type from entry values when the type is object, and improved property change tracking for JSON-mapped navigation properties.
Copy link
Contributor

Copilot AI left a 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 enhances the EntityHistoryHelper class to properly handle entities with shared CLR types and properties mapped to JSON columns in Entity Framework Core. The implementation addresses three key scenarios: (1) detecting and using metadata names for shared type entities, (2) determining actual property types at runtime when the declared type is object, and (3) recursively tracking changes in JSON-mapped navigation properties.

Key Changes

  • Added logic to detect shared CLR types and use metadata names instead of CLR type full names for entity identification
  • Introduced DeterminePropertyTypeFromEntry method to resolve actual property types from entry values when the declared type is object
  • Implemented recursive property change tracking for JSON-mapped navigation properties to capture nested entity changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…eworkCore/EntityHistory/EntityHistoryHelper.cs

Co-authored-by: Copilot <[email protected]>
@abpframework abpframework deleted a comment from Copilot AI Dec 30, 2025
@abpframework abpframework deleted a comment from Copilot AI Dec 30, 2025
Refactored EntityHistoryHelper to better handle property changes for navigation properties mapped to JSON. Now, nested property changes are prefixed with the navigation property name, and duplicate property names are handled to avoid conflicts.
Update EntityHistoryHelper to set the entity type name only for shared CLR types that are not owned entities. This prevents incorrect entity name assignment for owned types.
@maliming
Copy link
Member

hi

Can you add a unit test for the new method?

salihozkara and others added 3 commits December 31, 2025 11:40
Introduces AppEntityWithJsonProperty and related DbSet to test contexts, configures model to handle owned JSON properties, and adds tests to verify entity history tracking for nested JSON property changes and shared entities. Refactors EntityHistoryHelper to improve navigation property change handling.
@maliming maliming merged commit 185048f into dev Dec 31, 2025
2 of 3 checks passed
@maliming maliming deleted the salihozkara/improve-entity-changes branch December 31, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants