Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion entity-framework/core/providers/cosmos/modeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Modeling - Azure Cosmos DB Provider - EF Core
description: Configuring the model with the Azure Cosmos DB EF Core Provider
author: roji
ms.date: 09/26/2024
ms.date: 03/18/2026
Comment thread
roji marked this conversation as resolved.
Outdated
uid: core/providers/cosmos/modeling
---
# Configuring the model with the EF Core Azure Cosmos DB Provider
Expand Down
38 changes: 38 additions & 0 deletions entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ This enhancement removes a significant limitation when modeling complex domain h

For more information on inheritance mapping strategies, see [Inheritance](xref:core/modeling/inheritance).

<a name="complex-types-cosmos"></a>

### Complex types in Azure Cosmos DB

Complex types are now fully supported in the Azure Cosmos DB provider, embedded as nested JSON objects or arrays. For more information, [see the Cosmos DB section below](#cosmos-complex-types).

## LINQ and SQL translation

<a name="linq-maxby-minby"></a>
Expand Down Expand Up @@ -106,6 +112,38 @@ Similarly, `MinByAsync` orders ascending and returns the element with the minimu

## Cosmos DB

<a name="cosmos-complex-types"></a>

### Complex types

EF Core [complex types](xref:core/what-is-new/ef-core-10.0/whatsnew#complex-types) are now fully supported in the Azure Cosmos DB provider; they are embedded as nested JSON objects (or arrays, for collections) within the owning document, with support for queries, inserts, and updates.
Comment thread
roji marked this conversation as resolved.

For example, the following configures `ShippingAddress` as a complex type:

### [Fluent API](#tab/fluent-api)

```csharp
modelBuilder.Entity<Order>()
.ComplexProperty(o => o.ShippingAddress);
```
Comment thread
roji marked this conversation as resolved.
Outdated

### [Data Annotations](#tab/data-annotations)

Comment thread
roji marked this conversation as resolved.
Outdated
```csharp
[ComplexType]
Comment thread
roji marked this conversation as resolved.
public class ShippingAddress
{
public required string Street { get; set; }
public required string City { get; set; }
}
```

***

Complex types are generally a better fit than owned types when mapping to JSON documents: unlike owned types, complex types have value semantics and no identity, which means they work better in scenarios such as comparing two embedded objects within the same document, or using them as keys.
Comment thread
roji marked this conversation as resolved.
Outdated

This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!

<a name="cosmos-transactional-batches"></a>

### Transactional batches
Expand Down
Loading