Fix TableSharingConcurrencyTokenConvention to skip JSON-mapped entity types #37287
+91
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
TableSharingConcurrencyTokenConventionincorrectly creates shadow concurrency token properties on JSON-mapped owned entities, causing model validation to fail with:Repro:
Changes
IsMappedToJson()entity types when building table-to-entity mappings, consistent withValidateSharedTableCompatibilityFixes #36614
Original prompt
This section details on the original issue you should resolve
<issue_title>Conflict with RowVersion/Concurrency Token in TPH with Owned Entity as JSON (ValidateJsonProperties throws exception)</issue_title>
<issue_description>### Bug description
After upgrading from EF Core 9.x to 10.0.0, an exception is thrown during model building (e.g., EnsureCreated or during migrations) when the following combination is used:
This model works correctly in EF Core 9. Starting with EF Core 10, it fails with the following exception:
System.InvalidOperationException: Property 'OwnedEntity._TableSharingConcurrencyTokenConvention_RowVersion' cannot have both a column name ('RowVersion') and a JSON property name ('_TableSharingConcurrencyTokenConvention_RowVersion') configured. Properties in JSON-mapped types should use JSON property names, not column names.Expected Behavior
The model should be built without throwing an exception.
The RowVersion in the base class should work as a standard timestamp/rowversion column, and the owned JSON object should be validated independently without inheriting concurrency metadata.
Actual Behavior
During model creation (dbContext.Database.EnsureCreated()), EF Core throws an InvalidOperationException (full stack trace included in the sample project).
This prevents both model creation and migrations.
Issue.zip
Your code
Stack traces