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
@@ -77,6 +77,21 @@ This enhancement removes a significant limitation when modeling complex domain h
77
77
78
78
For more information on inheritance mapping strategies, see [Inheritance](xref:core/modeling/inheritance).
79
79
80
+
<aname="complex-types-stabilization"></a>
81
+
82
+
### Stabilization and bug fixes
83
+
84
+
Significant effort has gone into making sure that complex type support is stable and bug-free, to unblock using complex types as an alternative to the owned entity mapping approach. Bugs fixed include:
85
+
86
+
*[Error querying on complex type whose container is mapped to a table and a view](https://github.com/dotnet/efcore/issues/34706)
87
+
*[Problem with ComplexProperty in EF9, when using the TPT approach](https://github.com/dotnet/efcore/issues/35392)
88
+
*[Comparison of complex types does not compare properties within nested complex types](https://github.com/dotnet/efcore/issues/37391)
89
+
*[Assignment of complex type does not assign nested properties correctly (ExecuteUpdate)](https://github.com/dotnet/efcore/issues/37395)
90
+
*[Map two classes with same nullable complex properties to same column → NullReferenceException](https://github.com/dotnet/efcore/issues/37335)
91
+
*[Complex property stored as JSON marked non-nullable in TPH class hierarchy](https://github.com/dotnet/efcore/issues/37404)
92
+
*[EntityEntry.ReloadAsync throws when nullable complex property is null](https://github.com/dotnet/efcore/issues/37559)
93
+
*[Unnecessary columns in SQL with Complex Types + object closures in projections](https://github.com/dotnet/efcore/issues/37551)
94
+
80
95
## LINQ and SQL translation
81
96
82
97
<aname="linq-to-one-join-pruning"></a>
@@ -190,155 +205,6 @@ WHERE JSON_PATH_EXISTS([b].[JsonData], N'$.OptionalInt') = 1
190
205
191
206
For the full `JSON_PATH_EXISTS` SQL Server documentation, see [`JSON_PATH_EXISTS`](/sql/t-sql/functions/json-path-exists-transact-sql).
192
207
193
-
## Cosmos DB
194
-
195
-
<aname="cosmos-transactional-batches"></a>
196
-
197
-
### Transactional batches
198
-
199
-
Azure Cosmos DB supports [transactional batches](/azure/cosmos-db/transactional-batch), which allow multiple operations to be executed atomically and in a single roundtrip against a single partition. Starting with EF Core 11, the provider leverages transactional batches by default, providing best-effort atomicity and improved performance when saving changes.
200
-
201
-
The batching behavior can be controlled via the <xref:Microsoft.EntityFrameworkCore.AutoTransactionBehavior> property:
202
-
203
-
***Auto** (default): Operations are grouped into transactional batches by container and partition. Batches are executed sequentially; if a batch fails, subsequent batches are not executed.
204
-
***Never**: All operations are performed individually and sequentially (the pre-11 behavior).
205
-
***Always**: Requires all operations to fit in a single transactional batch; throws if they cannot.
206
-
207
-
For more information, [see the documentation](xref:core/providers/cosmos/saving#transactionality-and-transactional-batches).
208
-
209
-
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
210
-
211
-
<aname="cosmos-bulk-execution"></a>
212
-
213
-
### Bulk execution
214
-
215
-
Azure Cosmos DB supports _bulk execution_, which allows multiple document operations to be executed in parallel and across DbContext instances, significantly improving throughput when saving many entities at once. EF Core now supports enabling bulk execution:
For more information, [see the documentation](xref:core/providers/cosmos/saving#bulk-execution).
226
-
227
-
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
228
-
229
-
<aname="cosmos-session-tokens"></a>
230
-
231
-
### Session token management
232
-
233
-
Azure Cosmos DB uses session tokens to track read-your-writes consistency within a session. When running in an environment with multiple instances (e.g., with round-robin load balancing), you may need to manually manage session tokens to ensure consistency across requests.
234
-
235
-
EF Core now provides APIs to retrieve and set session tokens on a `DbContext`. To enable manual session token management, configure the `SessionTokenManagementMode()`:
// Later, in a different context instance, apply the session token before reading
252
-
context.Database.UseSessionToken(sessionToken);
253
-
varresult=awaitcontext.Documents.FindAsync(id);
254
-
```
255
-
256
-
For more information, [see the documentation](xref:core/providers/cosmos/saving#session-token-management).
257
-
258
-
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
259
-
260
-
## Migrations
261
-
262
-
<aname="migrations-exclude-fk"></a>
263
-
264
-
### Excluding foreign key constraints from migrations
265
-
266
-
It is now possible to configure a foreign key relationship in the EF model while preventing the corresponding database constraint from being created by migrations. This is useful for legacy databases without existing constraints, or in data synchronization scenarios where referential integrity constraints might conflict with the synchronization order:
267
-
268
-
```csharp
269
-
modelBuilder.Entity<Blog>()
270
-
.HasMany(e=>e.Posts)
271
-
.WithOne(e=>e.Blog)
272
-
.HasForeignKey(e=>e.BlogId)
273
-
.ExcludeForeignKeyFromMigrations();
274
-
```
275
-
276
-
The relationship is fully supported in EF for queries, change tracking, etc. Only the foreign key constraint in the database is suppressed; a database index is still created on the foreign key column.
277
-
278
-
For more information, see [Excluding foreign key constraints from migrations](xref:core/modeling/relationships/foreign-and-principal-keys#excluding-foreign-key-constraints-from-migrations).
279
-
280
-
<aname="migrations-snapshot-latest-id"></a>
281
-
282
-
### Latest migration ID recorded in model snapshot
283
-
284
-
When working in team environments, it's common for multiple developers to create migrations on separate branches. When these branches are merged, the migration trees can diverge, leading to issues that are sometimes difficult to detect.
285
-
286
-
Starting with EF Core 11, the model snapshot now records the ID of the latest migration. When two developers create migrations on divergent branches, both branches will modify this value in the model snapshot, causing a source control merge conflict. This conflict alerts the team that they need to resolve the divergence - typically by discarding one of the migration trees and creating a new, unified migration.
287
-
288
-
For more information on managing migrations in team environments, see [Migrations in Team Environments](xref:core/managing-schemas/migrations/teams).
289
-
290
-
<aname="migrations-add-and-apply"></a>
291
-
292
-
### Create and apply migrations in one step
293
-
294
-
The `dotnet ef database update` command now supports creating and applying a migration in a single step using the new `--add` option. This uses Roslyn to compile the migration at runtime, enabling scenarios like .NET Aspire and containerized applications where recompilation isn't possible:
295
-
296
-
```dotnetcli
297
-
dotnet ef database update InitialCreate --add
298
-
```
299
-
300
-
This command scaffolds a new migration named `InitialCreate`, compiles it using Roslyn, and immediately applies it to the database. The migration files are still saved to disk for source control and future recompilation. The same options available for `dotnet ef migrations add` can be used:
301
-
302
-
```dotnetcli
303
-
dotnet ef database update AddProducts --add --output-dir Migrations/Products --namespace MyApp.Migrations
### Connection and offline options for migrations remove
315
-
316
-
The `dotnet ef migrations remove` and `database drop` commands now accept `--connection` parameters, allowing you to specify the database connection string directly without needing to configure a default connection in your `DbContext`. Additionally, `migrations remove` supports the new `--offline` option to remove a migration without connecting to the database:
317
-
318
-
```console
319
-
# Remove migration with specific connection
320
-
dotnet ef migrations remove --connection "Server=prod;Database=MyDb;..."
321
-
322
-
# Remove migration without connecting to database (offline mode)
323
-
dotnet ef migrations remove --offline
324
-
325
-
# Revert and remove applied migration
326
-
dotnet ef migrations remove --force
327
-
328
-
# Drop specific database by connection string
329
-
dotnet ef database drop --connection "Server=test;Database=MyDb;..." --force
330
-
```
331
-
332
-
The `--offline` option skips the database connection check entirely, which is useful when the database is inaccessible or when you're certain the migration hasn't been applied. Note that `--offline` and `--force` cannot be used together, since `--force` requires a database connection to check if the migration has been applied before reverting it.
333
-
334
-
In PowerShell, use the `-Connection` and `-Offline` parameters:
@@ -518,6 +384,155 @@ WHERE JSON_CONTAINS([b].[JsonData], 8, N'$.Rating') = 1
518
384
519
385
For the full `JSON_CONTAINS` SQL Server documentation, see [`JSON_CONTAINS`](/sql/t-sql/functions/json-contains-transact-sql).
520
386
387
+
## Cosmos DB
388
+
389
+
<aname="cosmos-transactional-batches"></a>
390
+
391
+
### Transactional batches
392
+
393
+
Azure Cosmos DB supports [transactional batches](/azure/cosmos-db/transactional-batch), which allow multiple operations to be executed atomically and in a single roundtrip against a single partition. Starting with EF Core 11, the provider leverages transactional batches by default, providing best-effort atomicity and improved performance when saving changes.
394
+
395
+
The batching behavior can be controlled via the <xref:Microsoft.EntityFrameworkCore.AutoTransactionBehavior> property:
396
+
397
+
***Auto** (default): Operations are grouped into transactional batches by container and partition. Batches are executed sequentially; if a batch fails, subsequent batches are not executed.
398
+
***Never**: All operations are performed individually and sequentially (the pre-11 behavior).
399
+
***Always**: Requires all operations to fit in a single transactional batch; throws if they cannot.
400
+
401
+
For more information, [see the documentation](xref:core/providers/cosmos/saving#transactionality-and-transactional-batches).
402
+
403
+
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
404
+
405
+
<aname="cosmos-bulk-execution"></a>
406
+
407
+
### Bulk execution
408
+
409
+
Azure Cosmos DB supports _bulk execution_, which allows multiple document operations to be executed in parallel and across DbContext instances, significantly improving throughput when saving many entities at once. EF Core now supports enabling bulk execution:
For more information, [see the documentation](xref:core/providers/cosmos/saving#bulk-execution).
420
+
421
+
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
422
+
423
+
<aname="cosmos-session-tokens"></a>
424
+
425
+
### Session token management
426
+
427
+
Azure Cosmos DB uses session tokens to track read-your-writes consistency within a session. When running in an environment with multiple instances (e.g., with round-robin load balancing), you may need to manually manage session tokens to ensure consistency across requests.
428
+
429
+
EF Core now provides APIs to retrieve and set session tokens on a `DbContext`. To enable manual session token management, configure the `SessionTokenManagementMode()`:
// Later, in a different context instance, apply the session token before reading
446
+
context.Database.UseSessionToken(sessionToken);
447
+
varresult=awaitcontext.Documents.FindAsync(id);
448
+
```
449
+
450
+
For more information, [see the documentation](xref:core/providers/cosmos/saving#session-token-management).
451
+
452
+
This feature was contributed by [@JoasE](https://github.com/JoasE) - many thanks!
453
+
454
+
## Migrations
455
+
456
+
<aname="migrations-exclude-fk"></a>
457
+
458
+
### Excluding foreign key constraints from migrations
459
+
460
+
It is now possible to configure a foreign key relationship in the EF model while preventing the corresponding database constraint from being created by migrations. This is useful for legacy databases without existing constraints, or in data synchronization scenarios where referential integrity constraints might conflict with the synchronization order:
461
+
462
+
```csharp
463
+
modelBuilder.Entity<Blog>()
464
+
.HasMany(e=>e.Posts)
465
+
.WithOne(e=>e.Blog)
466
+
.HasForeignKey(e=>e.BlogId)
467
+
.ExcludeForeignKeyFromMigrations();
468
+
```
469
+
470
+
The relationship is fully supported in EF for queries, change tracking, etc. Only the foreign key constraint in the database is suppressed; a database index is still created on the foreign key column.
471
+
472
+
For more information, see [Excluding foreign key constraints from migrations](xref:core/modeling/relationships/foreign-and-principal-keys#excluding-foreign-key-constraints-from-migrations).
473
+
474
+
<aname="migrations-snapshot-latest-id"></a>
475
+
476
+
### Latest migration ID recorded in model snapshot
477
+
478
+
When working in team environments, it's common for multiple developers to create migrations on separate branches. When these branches are merged, the migration trees can diverge, leading to issues that are sometimes difficult to detect.
479
+
480
+
Starting with EF Core 11, the model snapshot now records the ID of the latest migration. When two developers create migrations on divergent branches, both branches will modify this value in the model snapshot, causing a source control merge conflict. This conflict alerts the team that they need to resolve the divergence - typically by discarding one of the migration trees and creating a new, unified migration.
481
+
482
+
For more information on managing migrations in team environments, see [Migrations in Team Environments](xref:core/managing-schemas/migrations/teams).
483
+
484
+
<aname="migrations-add-and-apply"></a>
485
+
486
+
### Create and apply migrations in one step
487
+
488
+
The `dotnet ef database update` command now supports creating and applying a migration in a single step using the new `--add` option. This uses Roslyn to compile the migration at runtime, enabling scenarios like .NET Aspire and containerized applications where recompilation isn't possible:
489
+
490
+
```dotnetcli
491
+
dotnet ef database update InitialCreate --add
492
+
```
493
+
494
+
This command scaffolds a new migration named `InitialCreate`, compiles it using Roslyn, and immediately applies it to the database. The migration files are still saved to disk for source control and future recompilation. The same options available for `dotnet ef migrations add` can be used:
495
+
496
+
```dotnetcli
497
+
dotnet ef database update AddProducts --add --output-dir Migrations/Products --namespace MyApp.Migrations
### Connection and offline options for migrations remove
509
+
510
+
The `dotnet ef migrations remove` and `database drop` commands now accept `--connection` parameters, allowing you to specify the database connection string directly without needing to configure a default connection in your `DbContext`. Additionally, `migrations remove` supports the new `--offline` option to remove a migration without connecting to the database:
511
+
512
+
```console
513
+
# Remove migration with specific connection
514
+
dotnet ef migrations remove --connection "Server=prod;Database=MyDb;..."
515
+
516
+
# Remove migration without connecting to database (offline mode)
517
+
dotnet ef migrations remove --offline
518
+
519
+
# Revert and remove applied migration
520
+
dotnet ef migrations remove --force
521
+
522
+
# Drop specific database by connection string
523
+
dotnet ef database drop --connection "Server=test;Database=MyDb;..." --force
524
+
```
525
+
526
+
The `--offline` option skips the database connection check entirely, which is useful when the database is inaccessible or when you're certain the migration hasn't been applied. Note that `--offline` and `--force` cannot be used together, since `--force` requires a database connection to check if the migration has been applied before reverting it.
527
+
528
+
In PowerShell, use the `-Connection` and `-Offline` parameters:
* The EF command-line tool now writes all logging and status messages to standard error, reserving standard output only for the command's actual expected output. For example, when generating a migration SQL script with `dotnet ef migrations script`, only the SQL is written to standard output.
0 commit comments