You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[release/11.0] Warn when collection properties are mapped as scalars - #39664
Description
In EF Core 11 Property() was changed to always map a member as a scalar even if it's a collection. This PR adds a warning when a collection-typed property is explicitly configured as a scalar and has no value converter, suggesting PrimitiveCollection() to avoid later query translation failures.
Customer impact
Applications that configure primitive collections with Property() may encounter query translation failures. The workaround is to configure the member with PrimitiveCollection(), however it's not obvious without this warning.
How found
Customer reported.
Regression
The scalar-mapping behavior was introduced in EF Core 11 as an intentional breaking change.
Testing
Tests added
Risk
Very low. The change just adds an ignorable warning.
AndriySvyryd
changed the title
[WIP] Fix unhelpful translation error for collection property in 11
Warn when collection properties are mapped as scalars
Nov 15, 2026
Adds model-validation diagnostics for collection-typed properties explicitly mapped as scalar properties, helping users identify when Property() should be replaced with PrimitiveCollection().
Changes:
Emits CoreEventId.AccidentalScalarCollection for explicitly scalar-mapped collection properties without converters, excluding strings, byte[], and primitive collections.
Adds localized warning resources, diagnostic logging integration, property metadata payloads, and public API baseline updates.
Adds core and SQL Server tests covering warning behavior, configuration, exclusions, and query translation.
AndriySvyryd
changed the title
Warn when collection properties are mapped as scalars
[release/11.0] Warn when collection properties are mapped as scalars
Nov 15, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active issues remain: the async sequence check can recommend an unsupported configuration, and non-shared fixtures still throw on existing collection-property mappings.
TryGetSequenceType() also recognizes IAsyncEnumerable<T>, but PrimitiveCollection() only resolves IEnumerable<T> (see InternalTypeBaseBuilder.PrimitiveCollection). An explicitly scalar IAsyncEnumerable<T> property can therefore trigger this warning even though the suggested PrimitiveCollection() configuration throws NotCollection; restrict this check to the sequence shape that PrimitiveCollection() actually supports (or add equivalent async-collection support).
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active issues are identified, and the change is supported by targeted model-validation, SQL Server, configuration, localization, diagnostics, and API-baseline updates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Fixes #39600
Description
In EF Core 11
Property()was changed to always map a member as a scalar even if it's a collection. This PR adds a warning when a collection-typed property is explicitly configured as a scalar and has no value converter, suggestingPrimitiveCollection()to avoid later query translation failures.Customer impact
Applications that configure primitive collections with
Property()may encounter query translation failures. The workaround is to configure the member withPrimitiveCollection(), however it's not obvious without this warning.How found
Customer reported.
Regression
The scalar-mapping behavior was introduced in EF Core 11 as an intentional breaking change.
Testing
Tests added
Risk
Very low. The change just adds an ignorable warning.