Repository navigation
Add model-wide and member JSON reader/writer configuration - #39483
Open
AndriySvyryd wants to merge 21 commits into
Open
AndriySvyryd wants to merge 21 commits into
AndriySvyryd wants to merge 21 commits into
Conversation
Code coverage overviewLanguages: C# C# / code-coverage
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Contributor
Agent harness evaluation is staleEvaluation does not run automatically for new commits. A contributor with write access can comment |
Simplify Cosmos partition routing and use native numeric mappings for pagination, array indexes, and counts. Remove the reader activation cache, validate convention-configured readers, and align runtime and compiled-model expectations. Add regression coverage and update Cosmos provider guidance. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use resolved JSON readers consistently for scalar updates, simplify provider handling, and allow numeric enum conversions during JSON reader validation. Memoize reader creation by type, update regressions, and revert the requested provider/query skill additions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use native scalar materialization, model-aware child mappings, lossless JSON updates, and weak reader/writer caching. Share UTF-8 serialization between relational and Cosmos providers, preserve concise JSON parameter names, and isolate per-mapping runtime values. Add regression coverage and refresh SQL, compiled-model, and API baselines. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Refresh SQL Server 2022-and-earlier JSON update assertions while preserving native-json baselines. - Remove the forced-GC reader cache test, its dynamic-assembly helper, and unused imports. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reuse existing big-model tests and baselines, remove standalone converted-key baselines, and revert skill-file additions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace JsonScalarTypeMapping with JsonTypePlaceholder lookup, preserve native scalar inference and stable JSON parameter sizes, explain API consistency exclusions, and update SQL Server baselines. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
AndriySvyryd
force-pushed
the
andriysvyryd-bulk-json-reader-configuration
branch
from
November 24, 2026 00:27
74eb6a4 to
5f9c860
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because an omitted finding identifies null-sentinel rounding that can cause SQL Server update paths to write values the reader cannot reload.
No open issues 🎉
2 resolved since last review
1 file not reviewed
src/EFCore/Properties/CoreStrings.Designer.cs: Generated file
Review effort: Balanced
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Summary
Applications need to customize JSON representations, including retaining the legacy
yyyy-MM-dd'T'HH:mm:ss.fffKDateTime format, without configuring every member through metadata annotations. This adds generic and Type-basedHasJsonValueReaderWriterAPIs for model-wide default type mappings, scalar properties, and primitive-collection elements, with configuration precedence and reset behavior. Primitive-collection builders expose element-level configuration only: whole-collection readers configured through metadata or applicable model defaults are rejected during validation.Reader/writers are expected to preserve the value they read, rather than act as converters. Value transformations belong in
ValueConverters. Arbitrary reader/writer implementations cannot be semantically validated; implementations that violate this contract may fail at runtime. This allows the provider implementation to use normal scalar materialization instead of reconstructing arbitrary JSON tokens for custom readers.Changes outside model builder and why
Type-mapping composition and nested values. Resolve the effective reader/writer after converters have been composed, while retaining intrinsic model-side readers for enums and collections. Resolve collection elements against model configuration, including Cosmos dictionary values and
ReadOnlyMemory<T>elements. Otherwise defaults can disappear inside nested containers, or a formatter can receive values of the wrong type or apply a conversion twice. Scalar strings/byte arrays, dictionary shapes, and self-referential sequences are excluded from generic element discovery to avoid incorrect or recursive mappings. Default-reader validation follows whether the property is actually persisted to JSON, including non-persisted Cosmos properties.Runtime models, compiled models, and activation. Store configured reader/writer types in metadata and carry them through runtime configuration and generated compiled models, preserving their activation members.
CreateFromTypememoizes activation in a weak-key Type cache without wrapping cached values. This keeps compiled and convention-built models consistent, avoids repeated activation, and does not permanently root collectible reader/writer types.SaveChanges and ExecuteUpdate. Serialize client-known scalar and collection values through their effective reader/writer for both full-document and partial updates. Numeric patches use the actual model/provider numeric value instead of inferring it from serialized JSON, avoiding precision loss. Serialized scalar parameters use native provider configuration without reapplying the property's converter. Runtime-selected mappings preserve scalar token types and SQL Server's string-size bucketing without imposing relational column precision/scale limits on JSON numbers. Serialized collections retain the target store type, including SQL Server's native
jsontype, so native JSON updates receive JSON fragments rather than strings. Row-dependent copying checks converter/provider representation compatibility, including the source store type: copying incompatible JSON or native representations cannot safely emulate client-side formatting on the server.Relational scalar queries and collection-parameter transport. Keep native scalar materialization; the thin SQLite JSON scalar mapping handles comparison literals/parameters, not JSON-token reconstruction or hidden projections. SQLite decodes JSON byte-array hex text to BLOBs in type-mapping postprocessing, and promoted integer comparison operands retain their range instead of being narrowed to the property's CLR type. Collection parameters used to query native SQL columns use provider transport readers while retaining converters, independently of model-default document formatting, including whole-collection defaults. An explicitly inferred element mapping determines transport serialization instead. This separates stored JSON formatting from the representations that native reads and
OPENJSON/json_eachtransport expect.Cosmos queries and SDK routing. Query constants, parameters, inline
Containsarrays, nested collections, and vector elements use the effective property/element mappings. Partition-key and resource-id values are also derived from their stored JSON representation, without reapplying a converter to an already converted provider value. Query comparisons and SDK point-read/routing requests must address the same values that document serialization writes; otherwise a correctly stored entity can be missed.Shared serialization and collection readers. Core exposes a shared internal UTF-8 serialization routine used by relational string serialization and Cosmos parameter/literal serialization. Cosmos retains its writer options without a string-to-UTF-8 round trip. Cosmos dictionary collection readers share their implementation and compose through the untyped reader/writer base, avoiding duplicated loops and invalid invariant-generic casts when a correctly configured reader returns an array.
Parameter identity and reuse. Separate the SQL placeholder
Namefrom the runtime lookupInvariantName. JSON ExecuteUpdate parameters retain short source names such asp/p0, but independently serialized values have unique runtime keys; parameter reuse also respects mapping compatibility. This prevents two JSON columns with different conversions from overwriting each other's serialization when both setters capture the same object, without exposing long internal names in SQL.Regression coverage includes legacy DateTime server comparisons on SQLite, SQL Server, and Cosmos; whole-collection default isolation in query transport; converted values and nested/typed collection readers; varying string lengths and precision-sensitive numeric updates; promoted scalar operands; compatible and rejected server-side copying; null handling and Cosmos routing; non-persisted property validation; reader activation/caching; and shared-parameter collisions. API, SQL, and compiled-model baselines are updated.
Fixes #31316
Fixes #31647
Fixes #33522
Fixes #39526