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
Copy file name to clipboardExpand all lines: entity-framework/core/providers/cosmos/unstructured-data.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,10 @@ EF Core was designed to make it easy to work with data that follows a schema def
11
11
12
12
## Accessing the raw JSON
13
13
14
-
It is possible to access the properties that are not tracked by EF Core through a special property in [shadow-state](xref:core/modeling/shadow-properties) named `"__jObject"` that contains a `JObject` representing the data received from the store and data that will be stored:
14
+
> [!NOTE]
15
+
> The `"__jObject"` shadow property was removed in EF Core 11. See [Breaking changes in EF Core 11](xref:core/what-is-new/ef-core-11.0/breaking-changes#cosmos-jObject-removed) for details.
16
+
17
+
In EF Core 10 and earlier, it was possible to access properties not tracked by EF Core through a special property in [shadow-state](xref:core/modeling/shadow-properties) named `"__jObject"` that contained a `JObject` representing the data received from the store and data that will be stored:
@@ -35,10 +38,7 @@ It is possible to access the properties that are not tracked by EF Core through
35
38
```
36
39
37
40
> [!WARNING]
38
-
> The `"__jObject"` property is part of the EF Core infrastructure and should only be used as a last resort as it is likely to have different behavior in future releases.
39
-
40
-
> [!NOTE]
41
-
> Changes to the entity will override the values stored in `"__jObject"` during `SaveChanges`.
41
+
> The `"__jObject"` property was part of the EF Core infrastructure and has been removed in EF Core 11. It should not be used in any version of EF Core as it is no longer available.
Previously, the Azure Cosmos DB provider added a shadow property named `"__jObject"` of type `JObject` (from `Newtonsoft.Json`) to every entity type. This property contained the raw JSON document as received from and sent to Cosmos DB, allowing access to unmapped or raw data:
EF Core used `Newtonsoft.Json` (via `JObject`) internally for all document serialization and deserialization.
59
+
60
+
#### New behavior
61
+
62
+
Starting with EF Core 11, the `__jObject` shadow property no longer exists. EF Core now uses `System.Text.Json` (`Utf8JsonReader`/`Utf8JsonWriter`) for document serialization and deserialization, and no longer depends on `Newtonsoft.Json`.
63
+
64
+
Accessing the `"__jObject"` property will throw an `InvalidOperationException`.
65
+
66
+
#### Why
67
+
68
+
The `JObject`-based approach required a dependency on `Newtonsoft.Json` and limited performance improvements. Switching to `System.Text.Json` aligns EF Core Cosmos with the rest of the .NET ecosystem and enables significant performance gains in the materializer.
69
+
70
+
#### Mitigations
71
+
72
+
To access the raw JSON document, use the `CosmosClient` directly instead of relying on `__jObject`:
Previously, when EF Core read a Cosmos DB document that contained JSON properties not mapped in the EF model, those extra properties were preserved in the `__jObject` shadow property and written back to the database on the next `SaveChanges`. Unmapped data in documents was transparently round-tripped.
92
+
93
+
#### New behavior
94
+
95
+
Starting with EF Core 11, unmapped JSON properties in a Cosmos DB document are ignored when reading. Any extra properties that are not part of the EF model will be lost if the entity is subsequently saved.
96
+
97
+
#### Why
98
+
99
+
Because `__jObject` has been removed (see above), there is no mechanism to preserve unmapped properties. EF Core 11 uses a lean JSON reader that only processes the properties it knows about from the model.
100
+
101
+
#### Mitigations
102
+
103
+
If your application relies on preserving unmapped data, consider one of the following options:
104
+
105
+
-**Use `CosmosClient` directly** for documents where you need full control over the JSON shape.
106
+
-**Map all relevant properties** explicitly in your EF model, including any extra fields that should be preserved.
107
+
37
108
## Medium-impact changes
38
109
39
110
<aname="cosmos-nosync"></a>
@@ -380,6 +451,34 @@ To restore the previous behavior where the discriminator property is also named
Previously, when a query projection returned a floating-point value (e.g., the result of a numeric expression such as `3 / 4` returned by Cosmos as `0.75`) and the target property was a fixed-point type (`int`, `long`, `decimal`, etc.), EF Core would **round** the value. For example, `0.75` would materialize as `1`.
463
+
464
+
#### New behavior
465
+
466
+
Starting with EF Core 11, such values are **truncated** instead of rounded. `0.75` now materializes as `0`, matching standard .NET integer truncation behavior (`(int)0.75 == 0`).
467
+
468
+
#### Why
469
+
470
+
Truncation is the standard .NET behavior for explicit numeric conversions and is consistent with how other providers behave. The previous rounding behavior was a bug.
471
+
472
+
#### Mitigations
473
+
474
+
If you relied on the previous rounding behavior, apply explicit rounding in your queries using `Math.Round`:
Copy file name to clipboardExpand all lines: entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -791,6 +791,19 @@ For more information, [see the documentation](xref:core/providers/cosmos/saving#
791
791
792
792
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
793
793
794
+
<aname="cosmos-modernized-materializer"></a>
795
+
796
+
### Modernized JSON serializer
797
+
798
+
EF Core 11 modernizes the Azure Cosmos DB provider's document serialization and deserialization to use `System.Text.Json` (`Utf8JsonReader`/`Utf8JsonWriter`) internally, replacing the previous `Newtonsoft.Json`-based approach. This improves performance and removes the dependency on `Newtonsoft.Json`.
799
+
800
+
As part of this change, the `__jObject` shadow property (of type `JObject`) that was previously added to every entity type has been removed, and unmapped JSON properties in documents are no longer preserved on round-trip.
801
+
802
+
> [!IMPORTANT]
803
+
> These are breaking changes. See the [breaking changes documentation](xref:core/what-is-new/ef-core-11.0/breaking-changes#cosmos-jObject-removed) for details and mitigations.
804
+
805
+
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
0 commit comments