From e57ffe1e20a53ba071b1a75ebfdeb174e09d8af1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 3 Jan 2026 02:06:39 +0000 Subject: [PATCH 01/10] Initial plan From e0f5c412d46192174867556afd07348d60b03294 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 3 Jan 2026 02:19:47 +0000 Subject: [PATCH 02/10] Add xref links to EF 9 and 10 API references in documentation Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../core/modeling/data-seeding.md | 18 +++++------ .../core/providers/cosmos/querying.md | 30 +++++++++---------- .../ef-core-9.0/breaking-changes.md | 24 +++++++-------- .../core/what-is-new/ef-core-9.0/whatsnew.md | 14 ++++----- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/entity-framework/core/modeling/data-seeding.md b/entity-framework/core/modeling/data-seeding.md index 22759ad633..0461ce6bf4 100644 --- a/entity-framework/core/modeling/data-seeding.md +++ b/entity-framework/core/modeling/data-seeding.md @@ -21,25 +21,25 @@ There are several ways this can be accomplished in EF Core: ## Configuration options `UseSeeding` and `UseAsyncSeeding` methods -EF 9 introduced `UseSeeding` and `UseAsyncSeeding` methods, which provide a convenient way of seeding the database with initial data. These methods aim to improve the experience of using custom initialization logic (explained below). They provide one clear location where all the data seeding code can be placed. Moreover, the code inside `UseSeeding` and `UseAsyncSeeding` methods is protected by the [migration locking mechanism](/ef/core/what-is-new/ef-core-9.0/whatsnew#concurrent-migrations) to prevent concurrency issues. +EF 9 introduced and methods, which provide a convenient way of seeding the database with initial data. These methods aim to improve the experience of using custom initialization logic (explained below). They provide one clear location where all the data seeding code can be placed. Moreover, the code inside and methods is protected by the [migration locking mechanism](/ef/core/what-is-new/ef-core-9.0/whatsnew#concurrent-migrations) to prevent concurrency issues. -The new seeding methods are called as part of [`EnsureCreated`](xref:Microsoft.EntityFrameworkCore.Storage.IDatabaseCreator.EnsureCreated) operation, [`Migrate`](/dotnet/api/microsoft.entityframeworkcore.relationaldatabasefacadeextensions.migrate) and `dotnet ef database update` command, even if there are no model changes and no migrations were applied. +The new seeding methods are called as part of operation, and `dotnet ef database update` command, even if there are no model changes and no migrations were applied. > [!TIP] -> Using `UseSeeding` and `UseAsyncSeeding` is the recommended way of seeding the database with initial data when working with EF Core. +> Using and is the recommended way of seeding the database with initial data when working with EF Core. These methods can be set up in the [options configuration step](/ef/core/dbcontext-configuration/#dbcontextoptions). Here is an example: [!code-csharp[ContextOptionSeeding](../../../samples/core/Modeling/DataSeeding/DataSeedingContext.cs?name=ContextOptionSeeding)] > [!NOTE] -> `UseSeeding` is called from the `EnsureCreated` method, and `UseAsyncSeeding` is called from the `EnsureCreatedAsync` method. When using this feature, it is recommended to implement both `UseSeeding` and `UseAsyncSeeding` methods using similar logic, even if the code using EF is asynchronous. EF Core tooling currently relies on the synchronous version of the method and will not seed the database correctly if the `UseSeeding` method is not implemented. +> is called from the method, and is called from the method. When using this feature, it is recommended to implement both and methods using similar logic, even if the code using EF is asynchronous. EF Core tooling currently relies on the synchronous version of the method and will not seed the database correctly if the method is not implemented. ## Custom initialization logic -A straightforward and powerful way to perform data seeding is to use [`DbContext.SaveChangesAsync()`](xref:core/saving/index) before the main application logic begins execution. It is recommended to use `UseSeeding` and `UseAsyncSeeding` for that purpose, however sometimes using these methods is not a good solution. An example scenario is when seeding requires using two different contexts in one transaction. Below is a code sample performing custom initialization in the application directly: +A straightforward and powerful way to perform data seeding is to use before the main application logic begins execution. It is recommended to use and for that purpose, however sometimes using these methods is not a good solution. An example scenario is when seeding requires using two different contexts in one transaction. Below is a code sample performing custom initialization in the application directly: [!code-csharp[Main](../../../samples/core/Modeling/DataSeeding/Program.cs?name=CustomSeeding)] @@ -85,10 +85,10 @@ Once the data has been added to the model, [migrations](xref:core/managing-schem > [!TIP] > If you need to apply migrations as part of an automated deployment you can [create a SQL script](xref:core/managing-schemas/migrations/applying#sql-scripts) that can be previewed before execution. -Alternatively, you can use `context.Database.EnsureCreatedAsync()` to create a new database containing the managed data, for example for a test database or when using the in-memory provider or any non-relational database. Note that if the database already exists, `EnsureCreatedAsync()` will neither update the schema nor managed data in the database. For relational databases you shouldn't call `EnsureCreatedAsync()` if you plan to use Migrations. +Alternatively, you can use to create a new database containing the managed data, for example for a test database or when using the in-memory provider or any non-relational database. Note that if the database already exists, will neither update the schema nor managed data in the database. For relational databases you shouldn't call if you plan to use Migrations. > [!NOTE] -> Populating the database using the `HasData` method used to be referred to as "data seeding". This naming sets incorrect expectations, as the feature has a number of limitations and is only appropriate for specific types of data. That is why we decided to rename it to "model managed data". `UseSeeding` and `UseAsyncSeeding` methods should be used for general purpose data seeding. +> Populating the database using the method used to be referred to as "data seeding". This naming sets incorrect expectations, as the feature has a number of limitations and is only appropriate for specific types of data. That is why we decided to rename it to "model managed data". and methods should be used for general purpose data seeding. ### Limitations of model managed data @@ -99,7 +99,7 @@ This type of data is managed by migrations and the script to update the data tha Therefore this feature is most useful for static data that's not expected to change outside of migrations and does not depend on anything else in the database, for example ZIP codes. -If your scenario includes any of the following it is recommended to use `UseSeeding` and `UseAsyncSeeding` methods described in the first section: +If your scenario includes any of the following it is recommended to use and methods described in the first section: * Temporary data for testing * Data that depends on database state @@ -113,6 +113,6 @@ If your scenario includes any of the following it is recommended to use `UseSeed ## Manual migration customization -When a migration is added the changes to the data specified with `HasData` are transformed to calls to `InsertData()`, `UpdateData()`, and `DeleteData()`. One way of working around some of the limitations of `HasData` is to manually add these calls or [custom operations](xref:core/managing-schemas/migrations/operations) to the migration instead. +When a migration is added the changes to the data specified with are transformed to calls to `InsertData()`, `UpdateData()`, and `DeleteData()`. One way of working around some of the limitations of is to manually add these calls or [custom operations](xref:core/managing-schemas/migrations/operations) to the migration instead. [!code-csharp[CustomInsert](../../../samples/core/Modeling/DataSeeding/Migrations/20241016041555_Initial.cs?name=CustomInsert)] diff --git a/entity-framework/core/providers/cosmos/querying.md b/entity-framework/core/providers/cosmos/querying.md index 089a75e315..430c3ec857 100644 --- a/entity-framework/core/providers/cosmos/querying.md +++ b/entity-framework/core/providers/cosmos/querying.md @@ -144,7 +144,7 @@ foreach (var session in firstPage.Values) } ``` -Rather than terminating the LINQ query with `ToListAsync` or similar, we use the `ToPageAsync` method, instructing it to get at most 10 items in every page (note that there may be fewer items in the database). Since this is our first query, we'd like to get results from the beginning, and pass `null` as the continuation token. `ToPageAsync` returns a `CosmosPage`, which exposes a continuation token and the values in the page (up to 10 items). Your program will typically send those values to the client, along with the continuation token; this will allow resuming the query later and fetching more results. +Rather than terminating the LINQ query with `ToListAsync` or similar, we use the method, instructing it to get at most 10 items in every page (note that there may be fewer items in the database). Since this is our first query, we'd like to get results from the beginning, and pass `null` as the continuation token. returns a , which exposes a continuation token and the values in the page (up to 10 items). Your program will typically send those values to the client, along with the continuation token; this will allow resuming the query later and fetching more results. Let's assume the user now clicks on the "Next" button in their UI, asking for the next 10 items. You can then execute the query as follows: @@ -164,7 +164,7 @@ To learn more about pagination in Azure Cosmos DB, [see this page](/azure/cosmos > [!NOTE] > Azure Cosmos DB does not support backwards pagination, and does not provide a count of the total pages or items. > -> `ToPageAsync` is currently annotated as experimental, since it may be replaced with a more generic EF pagination API that isn't Azure Cosmos DB specific. Although using the current API will generate a compilation warning (`EF9102`), doing so should be safe - future changes may require minor tweaks in the API shape. +> is currently annotated as experimental, since it may be replaced with a more generic EF pagination API that isn't Azure Cosmos DB specific. Although using the current API will generate a compilation warning (`EF9102`), doing so should be safe - future changes may require minor tweaks in the API shape. ## `FindAsync` @@ -209,7 +209,7 @@ FROM ( ) s ``` -Note that `FromSql` was introduced in EF 9.0. In previous versions, `FromSqlRaw` can be used instead, although note that that method is vulnerable to SQL injection attacks. +Note that was introduced in EF 9.0. In previous versions, can be used instead, although note that that method is vulnerable to SQL injection attacks. For more information on SQL querying, see the [relational documentation on SQL queries](xref:core/querying/sql-queries); most of that content is relevant for the Azure Cosmos DB provider as well. @@ -300,15 +300,15 @@ stringValue.TrimStart() | [LTRIM(@stri .NET | SQL | Added in --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ----- -EF.Functions.VectorDistance(vector1, vector2). | [VectorDistance(vector1, vector2)](/azure/cosmos-db/nosql/query/vectordistance) | EF 9 -EF.Functions.VectorDistance(vector1, vector2, bruteForce) | [VectorDistance(vector1, vector2, bruteForce)](/azure/cosmos-db/nosql/query/vectordistance) | EF 9 -EF.Functions.VectorDistance(vector1, vector2, bruteForce, distanceFunction) | [VectorDistance(vector1, vector2, bruteForce, distanceFunction)](/azure/cosmos-db/nosql/query/vectordistance) | EF 9 -EF.Functions.FullTextContains(property, keyword) | [FullTextContains(property, keyword)](/azure/cosmos-db/nosql/query/fulltextcontains) | EF 10 -EF.Functions.FullTextContainsAll(property, keyword1, keyword2) | [FullTextContainsAll(property, keyword1, keyword2)](/azure/cosmos-db/nosql/query/fulltextcontainsall) | EF 10 -EF.Functions.FullTextContainsAny(property, keyword1, keyword2) | [FullTextContainsAny(property, keyword1, keyword2)](/azure/cosmos-db/nosql/query/fulltextcontainsany) | EF 10 -EF.Functions.FullTextScore(property, keyword1, keyword2) | [FullTextScore(property, keyword1, keyword2)](/azure/cosmos-db/nosql/query/fulltextscore) | EF 10 -EF.Functions.Rrf(search1, search2) | [RRF(property, search1, search2)](/azure/cosmos-db/nosql/query/rrf). | EF 10 -EF.Functions.Rrf(new[] { search1, search2 }, weights) | [RRF(property, search1, search2, weights)](/azure/cosmos-db/nosql/query/rrf) | EF 10 +(vector1, vector2). | [VectorDistance(vector1, vector2)](/azure/cosmos-db/nosql/query/vectordistance) | EF 9 +(vector1, vector2, bruteForce) | [VectorDistance(vector1, vector2, bruteForce)](/azure/cosmos-db/nosql/query/vectordistance) | EF 9 +(vector1, vector2, bruteForce, distanceFunction) | [VectorDistance(vector1, vector2, bruteForce, distanceFunction)](/azure/cosmos-db/nosql/query/vectordistance) | EF 9 +(property, keyword) | [FullTextContains(property, keyword)](/azure/cosmos-db/nosql/query/fulltextcontains) | EF 10 +(property, keyword1, keyword2) | [FullTextContainsAll(property, keyword1, keyword2)](/azure/cosmos-db/nosql/query/fulltextcontainsall) | EF 10 +(property, keyword1, keyword2) | [FullTextContainsAny(property, keyword1, keyword2)](/azure/cosmos-db/nosql/query/fulltextcontainsany) | EF 10 +(property, keyword1, keyword2) | [FullTextScore(property, keyword1, keyword2)](/azure/cosmos-db/nosql/query/fulltextscore) | EF 10 +(search1, search2) | [RRF(property, search1, search2)](/azure/cosmos-db/nosql/query/rrf). | EF 10 +(new[] { search1, search2 }, weights) | [RRF(property, search1, search2, weights)](/azure/cosmos-db/nosql/query/rrf) | EF 10 For more information on vector search, see [the documentation](xref:core/providers/cosmos/vector-search). For more information on full-text search, see [the documentation](xref:core/providers/cosmos/full-text-search). @@ -317,7 +317,7 @@ For more information on vector search, see [the documentation](xref:core/provide .NET | SQL | Added in --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ----- collection.Contains(item) | @item IN @collection -EF.Functions.CoalesceUndefined(x, y)1 | [x ?? y](/azure/cosmos-db/nosql/query/ternary-coalesce-operators#coalesce-operator) | EF 9 -EF.Functions.IsDefined(x) | [IS_DEFINED(x)](/azure/cosmos-db/nosql/query/is-defined) | EF 9 +(x, y)1 | [x ?? y](/azure/cosmos-db/nosql/query/ternary-coalesce-operators#coalesce-operator) | EF 9 +(x) | [IS_DEFINED(x)](/azure/cosmos-db/nosql/query/is-defined) | EF 9 -1 Note that `EF.Functions.CoalesceUndefined` coalesces `undefined`, not `null`. To coalesce `null`, use the regular C# `??` operator. +1 Note that coalesces `undefined`, not `null`. To coalesce `null`, use the regular C# `??` operator. diff --git a/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md index 459cea6c47..8386226af2 100644 --- a/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md +++ b/entity-framework/core/what-is-new/ef-core-9.0/breaking-changes.md @@ -44,11 +44,11 @@ EF Core 9 targets .NET 8. This means that existing applications that target .NET #### Old behavior -If the model has pending changes compared to the last migration they are not applied with the rest of the migrations when `Migrate` is called. +If the model has pending changes compared to the last migration they are not applied with the rest of the migrations when is called. #### New behavior -Starting with EF Core 9.0, if the model has pending changes compared to the last migration an exception is thrown when `dotnet ef database update`, `Migrate` or `MigrateAsync` is called: +Starting with EF Core 9.0, if the model has pending changes compared to the last migration an exception is thrown when `dotnet ef database update`, or is called: > :::no-loc text="The model for context 'DbContext' has pending changes. Add a new migration before updating the database. This exception can be suppressed or logged by passing event ID 'RelationalEventId.PendingModelChangesWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'."::: #### Why @@ -60,16 +60,16 @@ Forgetting to add a new migration after making model changes is a common mistake There are several common situations when this exception can be thrown: - There are no migrations at all. This is common when the database is updated through other means. - - **Mitigation**: If you don't plan to use migrations for managing the database schema then remove the `Migrate` or `MigrateAsync` call, otherwise add a migration. + - **Mitigation**: If you don't plan to use migrations for managing the database schema then remove the or call, otherwise add a migration. - There is at least one migration, but the model snapshot is missing. This is common for migrations created manually. - **Mitigation**: Add a new migration using EF tooling, this will update the model snapshot. -- The model wasn't modified by the developer, but it's built in a non-deterministic way causing EF to detect it as modified. This is common when `new DateTime()`, `DateTime.Now`, `DateTime.UtcNow`, or `Guid.NewGuid()` are used in objects supplied to `HasData()`. - - **Mitigation**: Add a new migration, examine its contents to locate the cause, and replace the dynamic data with a static, hardcoded value in the model. The migration should be recreated after the model is fixed. If dynamic data has to be used for seeding consider using [the new seeding pattern](/ef/core/what-is-new/ef-core-9.0/whatsnew#improved-data-seeding) instead of `HasData()`. +- The model wasn't modified by the developer, but it's built in a non-deterministic way causing EF to detect it as modified. This is common when `new DateTime()`, `DateTime.Now`, `DateTime.UtcNow`, or `Guid.NewGuid()` are used in objects supplied to . + - **Mitigation**: Add a new migration, examine its contents to locate the cause, and replace the dynamic data with a static, hardcoded value in the model. The migration should be recreated after the model is fixed. If dynamic data has to be used for seeding consider using [the new seeding pattern](/ef/core/what-is-new/ef-core-9.0/whatsnew#improved-data-seeding) instead of . - The last migration was created for a different provider than the one used to apply the migrations. - **Mitigation**: This is an unsupported scenario. The warning can be suppressed using the code snippet below, but this scenario will likely stop working in a future EF Core release. The recommended solution is [to generate a separate set of migrations for each provider](xref:core/managing-schemas/migrations/providers). - The migrations are generated, modified or chosen dynamically by replacing some of the EF services. - **Mitigation**: The warning is a false positive in this case and should be suppressed: - `options.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning))` + `options.ConfigureWarnings(w => w.Ignore())` - You are using ASP.NET Core Identity and change options that affect the model, such as: ```csharp @@ -136,7 +136,7 @@ await dbContext.Database.CreateExecutionStrategy().ExecuteAsync(async () => #### New behavior -Starting with EF Core 9.0, `Migrate` and `MigrateAsync` calls will start a transaction and execute the commands using an `ExecutionStrategy` and if your app uses the above pattern an exception is thrown: +Starting with EF Core 9.0, and calls will start a transaction and execute the commands using an `ExecutionStrategy` and if your app uses the above pattern an exception is thrown: > :::no-loc text="An error was generated for warning 'Microsoft.EntityFrameworkCore.Migrations.MigrationsUserTransactionWarning': A transaction was started before applying migrations. This prevents a database lock to be acquired and hence the database will not be protected from concurrent migration applications. The transactions and execution strategy are already managed by EF as needed. Remove the external transaction. This exception can be suppressed or logged by passing event ID 'RelationalEventId.MigrationsUserTransactionWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'."::: #### Why @@ -154,7 +154,7 @@ await dbContext.Database.MigrateAsync(cancellationToken); Otherwise, if your scenario requires an explicit transaction and you have other mechanism in place to prevent concurrent migration application, then ignore the warning: ```csharp -options.ConfigureWarnings(w => w.Ignore(RelationalEventId.MigrationsUserTransactionWarning)) +options.ConfigureWarnings(w => w.Ignore()) ``` ## Medium-impact changes @@ -371,7 +371,7 @@ An emerging JSON practice uses a `$type` property in scenarios where a document' ##### Mitigations -The easiest mitigation is to simply configure the name of the discriminator property to be `Discriminator`, just as before: +The easiest mitigation is to simply configure the name of the discriminator property to be `Discriminator`, just as before using : ```csharp modelBuilder.Entity().HasDiscriminator("Discriminator"); @@ -403,7 +403,7 @@ EF 9.0 generally changed the mapping to be more aligned with common Azure Cosmos ##### Mitigations -The easiest mitigation is to simply configure EF to include the discriminator in the JSON `id` property, as before. A new configuration option has been introduced for this purpose: +The easiest mitigation is to simply configure EF to include the discriminator in the JSON `id` property, as before using . A new configuration option has been introduced for this purpose: ```csharp modelBuilder.Entity().HasDiscriminatorInJsonId(); @@ -433,13 +433,13 @@ EF 9.0 generally changed the mapping to be more aligned with common Azure Cosmos ##### Mitigations -If you would like to preserve EF Core 8 behavior the easiest mitigation is to use a new configuration option that has been introduced for this purpose: +If you would like to preserve EF Core 8 behavior the easiest mitigation is to use , a new configuration option that has been introduced for this purpose: ```csharp modelBuilder.Entity().HasShadowId(); ``` -Doing this for all your top-level entity types will make EF behave just like before. Or you could apply it to all entity types in the model with one call: +Doing this for all your top-level entity types will make EF behave just like before. Or you could apply it to all entity types in the model with one call using : ```csharp modelBuilder.HasShadowIds(); diff --git a/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md b/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md index dd6003db2b..26e9f73c24 100644 --- a/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md +++ b/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md @@ -153,7 +153,7 @@ In EF 9.0, the LINQ translation capabilities of the the Azure Cosmos DB provider * Support for aggregate operators such as `Count` and `Sum`. * Additional function translations (see the [function mappings documentation](xref:core/providers/cosmos/querying#function-mappings) for the full list of supported translations): * Translations for `DateTime` and `DateTimeOffset` component members (`DateTime.Year`, `DateTimeOffset.Month`...). - * `EF.Functions.IsDefined` and `EF.Functions.CoalesceUndefined` now allow dealing with `undefined` values. + * and now allow dealing with `undefined` values. * `string.Contains`, `StartsWith` and `EndsWith` now support `StringComparison.OrdinalIgnoreCase`. For the full list of querying improvements, see [this issue](https://github.com/dotnet/efcore/issues/33033): @@ -229,7 +229,7 @@ public class BloggingContext } ``` -Once that's done, use the `EF.Functions.VectorDistance()` function in LINQ queries to perform vector similarity search: +Once that's done, use the function in LINQ queries to perform vector similarity search: ```c# var blogs = await context.Blogs @@ -256,7 +256,7 @@ foreach (var post in page.Values) } ``` -The new `ToPageAsync` operator returns a `CosmosPage`, which exposes a continuation token that can be used to efficiently resume the query at a later point, fetching the next 10 items: +The new operator returns a , which exposes a continuation token that can be used to efficiently resume the query at a later point, fetching the next 10 items: ```c# var nextPage = await context.Sessions.OrderBy(s => s.Id).ToPageAsync(10, continuationToken); @@ -266,7 +266,7 @@ For more information, [see the documentation section on pagination](xref:core/pr ### FromSql for safer SQL querying -The Azure Cosmos DB provider has allowed SQL querying via . However, that API can be susceptible to SQL injection attacks when user-provided data is interpolated or concatenated into the SQL. In EF 9.0, you can now use the new `FromSql` method, which always integrates parameterized data as a parameter outside the SQL: +The Azure Cosmos DB provider has allowed SQL querying via . However, that API can be susceptible to SQL injection attacks when user-provided data is interpolated or concatenated into the SQL. In EF 9.0, you can now use the new method, which always integrates parameterized data as a parameter outside the SQL: ```c# var maxAngle = 8; @@ -279,7 +279,7 @@ For more information, [see the documentation section on pagination](xref:core/pr ### Role-based access -Azure Cosmos DB for NoSQL includes a [built-in role-based access control (RBAC) system](/azure/cosmos-db/role-based-access-control). This is now supported by EF9 for all data plane operations. However, Azure Cosmos DB SDK does not support RBAC for management plane operations in Azure Cosmos DB. Use Azure Management API instead of `EnsureCreatedAsync` with RBAC. +Azure Cosmos DB for NoSQL includes a [built-in role-based access control (RBAC) system](/azure/cosmos-db/role-based-access-control). This is now supported by EF9 for all data plane operations. However, Azure Cosmos DB SDK does not support RBAC for management plane operations in Azure Cosmos DB. Use Azure Management API instead of with RBAC. ### Synchronous I/O is now blocked by default @@ -1099,10 +1099,10 @@ The majority of operations performed during migrations are protected by a transa ### Improved data seeding -EF9 introduced a convenient way to perform data seeding, that is populating the database with initial data. `DbContextOptionsBuilder` now contains `UseSeeding` and `UseAsyncSeeding` methods which get executed when the DbContext is initialized (as part of `EnsureCreatedAsync`). +EF9 introduced a convenient way to perform data seeding, that is populating the database with initial data. now contains and methods which get executed when the DbContext is initialized (as part of ). > [!NOTE] -> If the application had ran previously, the database may already contain the sample data (which would have been added on the first initialization of the context). As such, `UseSeeding` `UseAsyncSeeding` should check if data exists before attempting to populate the database. This can be achieved by issuing a simple EF query. +> If the application had ran previously, the database may already contain the sample data (which would have been added on the first initialization of the context). As such, should check if data exists before attempting to populate the database. This can be achieved by issuing a simple EF query. Here is an example of how these methods can be used: From 1e9a92ae1048998be113f1082f43cc4ffd705a16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 3 Jan 2026 02:23:37 +0000 Subject: [PATCH 03/10] Add additional xref links for EF.Constant, EF.Parameter, ExecuteUpdate, HasFillFactor, and ApplyConfigurationsFromAssembly Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../core/what-is-new/ef-core-9.0/whatsnew.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md b/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md index 26e9f73c24..6246b3ce82 100644 --- a/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md +++ b/entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md @@ -367,7 +367,7 @@ GROUP BY [s].[StoreAddress_City], [s].[StoreAddress_Country], [s].[StoreAddress_ > [!TIP] > The code shown here comes from [ExecuteUpdateSample.cs](https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/Miscellaneous/NewInEFCore9/ExecuteUpdateSample.cs). -Similarly, in EF9 `ExecuteUpdate` has also been improved to accept complex type properties. However, each member of the complex type must be specified explicitly. For example: +Similarly, in EF9 has also been improved to accept complex type properties. However, each member of the complex type must be specified explicitly. For example: