dotnet / dotnet/efcore

JSON: Allow weakly-typed mapping via Dictionary

Open
#29,825 17 comments 129 reactions 0 assignees View on GitHub
area-primitive-collections
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

#28871 tracks weakly-typed JSON mapping via JsonDocument/JsonElement, where the JSON document schema varies and so a strongly-typed model isn't appropriate.

We can also allow simply mapping arbitrary Dictionary types - this corresponds to how many people use

* This intersects with [#28688](https://github.com/dotnet/efcore/issues/28688) (primitive collections in JSON).
* Both keys and values should support any valid JSON data type (string, int...).
* However we could also support `Dictionary`, to map an entire hierarchy. See [#26903](https://github.com/dotnet/efcore/issues/26903) on this (currently seemed blocked by property bag detection).
* This should be supported at the top-level, so that the JSON object as a whole is mapped as a single dictionary (see e.g. [this issue](https://github.com/dotnet/efcore/issues/26903#issuecomment-1345392217)). This would mean supporting `OwnsOne(x => x.Json, builder => { builder.ToJson(); })` where x.Json is a Dictionary.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.