From aed0fbbec8944b565f8d49c0a59637cb36b10e2e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 20:17:22 +0000 Subject: [PATCH 01/10] Initial plan From 3c2e6f28e520ff2b2224071a3bdcee3a208d1d50 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 20:27:03 +0000 Subject: [PATCH 02/10] Add documentation for multiple AddDbContext calls behavior in EF Core 8.0 Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../core/dbcontext-configuration/index.md | 80 ++++++++++++ .../ef-core-8.0/breaking-changes.md | 26 +++- .../ConfigureDbContextSample.csproj | 17 +++ .../ConfigureDbContextSample/Program.cs | 121 ++++++++++++++++++ 4 files changed, 240 insertions(+), 4 deletions(-) create mode 100644 samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj create mode 100644 samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs diff --git a/entity-framework/core/dbcontext-configuration/index.md b/entity-framework/core/dbcontext-configuration/index.md index 55d3738ccb..fb79cbd1ea 100644 --- a/entity-framework/core/dbcontext-configuration/index.md +++ b/entity-framework/core/dbcontext-configuration/index.md @@ -90,6 +90,86 @@ The final result is an `ApplicationDbContext` instance created for each request Read further in this article to learn more about configuration options. See [Dependency injection in ASP.NET Core](/aspnet/core/fundamentals/dependency-injection) for more information. +## Multiple AddDbContext calls and configuration precedence + +Starting with EF Core 8.0, when multiple `AddDbContext` calls are made with the same context type, the **last call takes precedence** over earlier calls. This change was made to provide consistent configuration behavior and allow for better configuration override scenarios. + +### Basic usage with multiple AddDbContext calls + +When you register the same `DbContext` type multiple times, the final registration will be used: + + +[!code-csharp[MultipleAddDbContextCalls](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=MultipleAddDbContextCalls)] + +### Configuration precedence scenarios + +This change is particularly useful in scenarios where: + +- Libraries provide default `DbContext` configuration +- Applications need to override library defaults +- Different modules or components need to modify the same context configuration + +For example, a library might provide a default configuration: + +```csharp +// Library's default configuration +services.AddDbContext(options => + options.UseSqlServer(defaultConnectionString)); +``` + +And the application can then override it: + +```csharp +// Application's override - this will be used in EF Core 8.0 +services.AddDbContext(options => + options.UseSqlite(customConnectionString) + .EnableSensitiveDataLogging()); +``` + +> [!IMPORTANT] +> **Breaking change in EF Core 8.0**: In EF Core 7.0 and earlier, the first `AddDbContext` call would take precedence. Starting with EF Core 8.0, the last call takes precedence. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information and migration guidance. + +### Alternative approaches for conditional configuration + +If you need conditional configuration based on runtime conditions, consider using a factory pattern or options configuration: + + +[!code-csharp[ConditionalConfiguration](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=ConditionalConfiguration)] + ## Basic DbContext initialization with 'new' diff --git a/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md index 95795d99fd..f181ee4db0 100644 --- a/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md +++ b/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md @@ -627,19 +627,37 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) #### Old behavior -Previously, when multiple calls to `AddDbContext`, `AddDbContextPool`, `AddDbContextFactory` or `AddPooledDbContextFactor` were made with the same context type but conflicting configuration, the first one won. +Previously, when multiple calls to `AddDbContext`, `AddDbContextPool`, `AddDbContextFactory` or `AddPooledDbContextFactory` were made with the same context type but conflicting configuration, the first one won. + +For example: + +```csharp +services.AddDbContext(options => options.UseSqlServer(connectionString1)); +services.AddDbContext(options => options.UseSqlite(connectionString2)); // This was ignored + +// The context would use SQL Server (connectionString1) +``` #### New behavior -Starting with EF Core 8.0, the configuration from the last call one will take precedence. +Starting with EF Core 8.0, the configuration from the last call will take precedence. + +Using the same example: + +```csharp +services.AddDbContext(options => options.UseSqlServer(connectionString1)); // This is now ignored +services.AddDbContext(options => options.UseSqlite(connectionString2)); + +// The context will now use SQLite (connectionString2) +``` #### Why -This was changed to be consistent with the new method `ConfigureDbContext` that can be used to add configuration either before or after the `Add*` methods. +This was changed to be consistent with the new method `ConfigureDbContext` that can be used to add configuration either before or after the `Add*` methods. With the new `ConfigureDbContext` method, the last configuration call should take precedence to allow for proper configuration override scenarios. #### Mitigations -Reverse the order of `Add*` calls. +Reverse the order of `Add*` calls if you were depending on the previous behavior. diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj new file mode 100644 index 0000000000..b7829f2df5 --- /dev/null +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj @@ -0,0 +1,17 @@ + + + + Exe + net8.0 + enable + + + + + + + + + + + \ No newline at end of file diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs new file mode 100644 index 0000000000..c7b10736e5 --- /dev/null +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs @@ -0,0 +1,121 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace ConfigureDbContextSample; + +#region BlogContext +public class BlogContext : DbContext +{ + public BlogContext(DbContextOptions options) : base(options) + { + } + + public DbSet Blogs => Set(); +} + +public class Blog +{ + public int Id { get; set; } + public required string Title { get; set; } + public string? Content { get; set; } +} +#endregion + +public class Program +{ + public static void Main(string[] args) + { + BasicAddDbContextExample(); + MultipleAddDbContextCallsExample(); + ConditionalConfigurationExample(); + } + + private static void BasicAddDbContextExample() + { + Console.WriteLine("=== Basic AddDbContext Example ==="); + + #region BasicAddDbContext + var services = new ServiceCollection(); + + // DbContext registration with configuration + services.AddDbContext(options => + options.UseInMemoryDatabase("BasicExample") + .EnableSensitiveDataLogging() + .EnableDetailedErrors()); + + var serviceProvider = services.BuildServiceProvider(); + #endregion + + using var scope = serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + + Console.WriteLine($"Context configured successfully with provider: {context.Database.ProviderName}"); + Console.WriteLine(); + } + + private static void MultipleAddDbContextCallsExample() + { + Console.WriteLine("=== Multiple AddDbContext Calls Example (EF Core 8.0 Behavior) ==="); + + #region MultipleAddDbContextCalls + var services = new ServiceCollection(); + + // First configuration - will be overridden in EF Core 8.0 + services.AddDbContext(options => + options.UseInMemoryDatabase("FirstDatabase")); + + // Second configuration - this takes precedence (EF Core 8.0 behavior) + services.AddDbContext(options => + options.UseInMemoryDatabase("SecondDatabase") + .EnableSensitiveDataLogging()); + + var serviceProvider = services.BuildServiceProvider(); + #endregion + + using var scope = serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + + Console.WriteLine($"Provider: {context.Database.ProviderName}"); + Console.WriteLine("Note: In EF Core 8.0, the second AddDbContext call takes precedence over the first one."); + Console.WriteLine("This is different from EF Core 7.0 and earlier where the first call would win."); + Console.WriteLine(); + } + + private static void ConditionalConfigurationExample() + { + Console.WriteLine("=== Conditional Configuration Example ==="); + + #region ConditionalConfiguration + var services = new ServiceCollection(); + + // Mock environment and configuration services + var isDevelopment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development"; + + services.AddDbContext((serviceProvider, options) => + { + if (isDevelopment) + { + options.UseInMemoryDatabase("DevelopmentDatabase") + .EnableSensitiveDataLogging() + .EnableDetailedErrors(); + } + else + { + options.UseInMemoryDatabase("ProductionDatabase"); + } + }); + + var serviceProvider = services.BuildServiceProvider(); + #endregion + + using var scope = serviceProvider.CreateScope(); + var context = scope.ServiceProvider.GetRequiredService(); + + Console.WriteLine($"Context configured for environment: {(isDevelopment ? "Development" : "Production")}"); + Console.WriteLine($"Provider: {context.Database.ProviderName}"); + Console.WriteLine(); + } +} \ No newline at end of file From fc3ce371cb58ac25b7872c89a1a885612e9ac9b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 26 Sep 2025 20:29:39 +0000 Subject: [PATCH 03/10] Final documentation updates for AddDbContext precedence behavior Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../core/dbcontext-configuration/index.md | 15 ++++++++++++--- .../what-is-new/ef-core-8.0/breaking-changes.md | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/entity-framework/core/dbcontext-configuration/index.md b/entity-framework/core/dbcontext-configuration/index.md index fb79cbd1ea..53312858e3 100644 --- a/entity-framework/core/dbcontext-configuration/index.md +++ b/entity-framework/core/dbcontext-configuration/index.md @@ -94,6 +94,18 @@ Read further in this article to learn more about configuration options. See [Dep Starting with EF Core 8.0, when multiple `AddDbContext` calls are made with the same context type, the **last call takes precedence** over earlier calls. This change was made to provide consistent configuration behavior and allow for better configuration override scenarios. +> [!IMPORTANT] +> **Breaking change in EF Core 8.0**: In EF Core 7.0 and earlier, the first `AddDbContext` call would take precedence. Starting with EF Core 8.0, the last call takes precedence. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information and migration guidance. + +### When multiple AddDbContext calls occur + +Multiple `AddDbContext` calls for the same context type can happen in several scenarios: + +- **Library and application integration**: A library provides default configuration, and the application overrides it +- **Modular applications**: Different modules or components configure the same context +- **Environment-specific configuration**: Different configurations are applied based on conditions +- **Testing scenarios**: Test-specific configurations override application defaults + ### Basic usage with multiple AddDbContext calls When you register the same `DbContext` type multiple times, the final registration will be used: @@ -139,9 +151,6 @@ services.AddDbContext(options => .EnableSensitiveDataLogging()); ``` -> [!IMPORTANT] -> **Breaking change in EF Core 8.0**: In EF Core 7.0 and earlier, the first `AddDbContext` call would take precedence. Starting with EF Core 8.0, the last call takes precedence. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information and migration guidance. - ### Alternative approaches for conditional configuration If you need conditional configuration based on runtime conditions, consider using a factory pattern or options configuration: diff --git a/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md index f181ee4db0..932d7720ed 100644 --- a/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md +++ b/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md @@ -653,7 +653,7 @@ services.AddDbContext(options => options.UseSqlite(connectionString #### Why -This was changed to be consistent with the new method `ConfigureDbContext` that can be used to add configuration either before or after the `Add*` methods. With the new `ConfigureDbContext` method, the last configuration call should take precedence to allow for proper configuration override scenarios. +This was changed to provide consistent configuration behavior and support scenarios where multiple components need to configure the same `DbContext` type, with later configuration taking precedence over earlier ones. #### Mitigations From 5d80627dabcd2aeafd0e6e23ce2e07977c17e9fc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:16:24 +0000 Subject: [PATCH 04/10] Update documentation to properly document ConfigureDbContext method and improve breaking changes Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../core/dbcontext-configuration/index.md | 133 +++++++++--------- .../ef-core-8.0/breaking-changes.md | 49 ++++--- .../ConfigureDbContextSample.csproj | 10 +- .../ConfigureDbContextSample/Program.cs | 107 +++++++------- 4 files changed, 163 insertions(+), 136 deletions(-) diff --git a/entity-framework/core/dbcontext-configuration/index.md b/entity-framework/core/dbcontext-configuration/index.md index 53312858e3..e451ef2fc2 100644 --- a/entity-framework/core/dbcontext-configuration/index.md +++ b/entity-framework/core/dbcontext-configuration/index.md @@ -90,94 +90,95 @@ The final result is an `ApplicationDbContext` instance created for each request Read further in this article to learn more about configuration options. See [Dependency injection in ASP.NET Core](/aspnet/core/fundamentals/dependency-injection) for more information. -## Multiple AddDbContext calls and configuration precedence + -Starting with EF Core 8.0, when multiple `AddDbContext` calls are made with the same context type, the **last call takes precedence** over earlier calls. This change was made to provide consistent configuration behavior and allow for better configuration override scenarios. +## ConfigureDbContext for configuration composition -> [!IMPORTANT] -> **Breaking change in EF Core 8.0**: In EF Core 7.0 and earlier, the first `AddDbContext` call would take precedence. Starting with EF Core 8.0, the last call takes precedence. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information and migration guidance. - -### When multiple AddDbContext calls occur - -Multiple `AddDbContext` calls for the same context type can happen in several scenarios: - -- **Library and application integration**: A library provides default configuration, and the application overrides it -- **Modular applications**: Different modules or components configure the same context -- **Environment-specific configuration**: Different configurations are applied based on conditions -- **Testing scenarios**: Test-specific configurations override application defaults +Starting with EF Core 9.0, you can use `ConfigureDbContext` to apply additional configuration to a `DbContext` either before or after the `AddDbContext` call. This is particularly useful for composing non-conflicting, non-provider-specific configuration in reusable components or tests. -### Basic usage with multiple AddDbContext calls +### Basic ConfigureDbContext usage -When you register the same `DbContext` type multiple times, the final registration will be used: +`ConfigureDbContext` allows you to add configuration without replacing the entire provider configuration: - -[!code-csharp[MultipleAddDbContextCalls](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=MultipleAddDbContextCalls)] +`ConfigureDbContext` is especially useful when creating reusable components that need to add configuration without knowing or modifying the database provider: -### Configuration precedence scenarios +```csharp +// In a testing utility library +public static class TestingExtensions +{ + public static IServiceCollection AddTestingConfiguration( + this IServiceCollection services) + where TContext : DbContext + { + services.ConfigureDbContext(options => + options.EnableSensitiveDataLogging() + .EnableDetailedErrors() + .LogTo(Console.WriteLine)); + + return services; + } +} -This change is particularly useful in scenarios where: +// In your test +services.AddTestingConfiguration(); +services.AddDbContext(options => + options.UseInMemoryDatabase("TestDb")); +``` -- Libraries provide default `DbContext` configuration -- Applications need to override library defaults -- Different modules or components need to modify the same context configuration +### Provider-specific configuration without connection strings -For example, a library might provide a default configuration: +When you need to apply provider-specific configuration but don't have the connection string, you can use provider-specific configuration methods like `ConfigureSqlEngine`: ```csharp -// Library's default configuration -services.AddDbContext(options => - options.UseSqlServer(defaultConnectionString)); +// Configure SQL Server-specific options without knowing the connection string +services.ConfigureDbContext(options => + options.UseSqlServer(sqlOptions => + sqlOptions.EnableRetryOnFailure() + .CommandTimeout(30))); + +// Later, add the context with the connection string +services.AddDbContext(options => + options.UseSqlServer(connectionString)); ``` -And the application can then override it: +### ConfigureDbContext and AddDbContext precedence + +When both `ConfigureDbContext` and `AddDbContext` are used, or when multiple calls to these methods are made, the configuration is applied in the order the methods are called, with later calls taking precedence for conflicting options. + +For non-conflicting options (like adding logging, interceptors, or other settings), all configurations are composed together: ```csharp -// Application's override - this will be used in EF Core 8.0 -services.AddDbContext(options => - options.UseSqlite(customConnectionString) - .EnableSensitiveDataLogging()); -``` +// First: add logging +services.ConfigureDbContext(options => + options.LogTo(Console.WriteLine)); -### Alternative approaches for conditional configuration +// Second: add the provider +services.AddDbContext(options => + options.UseSqlServer(connectionString)); -If you need conditional configuration based on runtime conditions, consider using a factory pattern or options configuration: +// Third: add sensitive data logging +services.ConfigureDbContext(options => + options.EnableSensitiveDataLogging()); - -[!code-csharp[ConditionalConfiguration](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=ConditionalConfiguration)] +For conflicting options (like specifying different database providers), the last configuration wins. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information about this behavior change. diff --git a/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md b/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md index 932d7720ed..4ff9378494 100644 --- a/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md +++ b/entity-framework/core/what-is-new/ef-core-8.0/breaking-changes.md @@ -629,35 +629,48 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) Previously, when multiple calls to `AddDbContext`, `AddDbContextPool`, `AddDbContextFactory` or `AddPooledDbContextFactory` were made with the same context type but conflicting configuration, the first one won. -For example: +#### New behavior -```csharp -services.AddDbContext(options => options.UseSqlServer(connectionString1)); -services.AddDbContext(options => options.UseSqlite(connectionString2)); // This was ignored +Starting with EF Core 8.0, the configuration from the last call will take precedence. -// The context would use SQL Server (connectionString1) -``` +#### Why -#### New behavior +This was changed to be consistent with the new method `ConfigureDbContext`, that enables configuration composability for non-conflicting configurations. See [DbContext configuration](xref:core/dbcontext-configuration/index#configuredbcontext) for more information. -Starting with EF Core 8.0, the configuration from the last call will take precedence. +#### Mitigations -Using the same example: +If your application depends on the previous behavior where the first registration wins, you have several options: -```csharp -services.AddDbContext(options => options.UseSqlServer(connectionString1)); // This is now ignored -services.AddDbContext(options => options.UseSqlite(connectionString2)); +1. **Reorder your registrations**: Place the registration with the configuration you want to use last: -// The context will now use SQLite (connectionString2) -``` + ```csharp + services.AddDbContext(options => + options.UseSqlServer("connection1")); // This will be ignored now + + services.AddDbContext(options => + options.UseSqlServer("connection2")); // This will be used + ``` -#### Why +2. **Remove previous registrations**: If possible, remove the conflicting registration. -This was changed to provide consistent configuration behavior and support scenarios where multiple components need to configure the same `DbContext` type, with later configuration taking precedence over earlier ones. +3. **Use conditional registration**: Check if the service is already registered before adding: -#### Mitigations + ```csharp + if (!services.Any(d => d.ServiceType == typeof(DbContextOptions))) + { + services.AddDbContext(options => + options.UseSqlServer("connection")); + } + ``` + +4. **Use the new `ConfigureDbContext` method**: This allows you to configure options without registering the context itself. See [DbContext configuration](xref:core/dbcontext-configuration/index#configuredbcontext) for more information: -Reverse the order of `Add*` calls if you were depending on the previous behavior. + ```csharp + services.ConfigureDbContext(options => + options.UseSqlServer("connection")); + + services.AddDbContext(); // Register the context without configuration + ``` diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj index b7829f2df5..eeb276be74 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj @@ -7,11 +7,11 @@ - - - - - + + + + + \ No newline at end of file diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs index c7b10736e5..2cbab58c7d 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs @@ -24,53 +24,72 @@ public class Blog } #endregion +#region TestingExtensions +public static class TestingExtensions +{ + public static IServiceCollection AddTestingConfiguration( + this IServiceCollection services) + where TContext : DbContext + { + services.ConfigureDbContext(options => + options.EnableSensitiveDataLogging() + .EnableDetailedErrors() + .LogTo(Console.WriteLine)); + + return services; + } +} +#endregion + public class Program { public static void Main(string[] args) { - BasicAddDbContextExample(); - MultipleAddDbContextCallsExample(); - ConditionalConfigurationExample(); + BasicConfigureDbContextExample(); + ReusableComponentExample(); + ConfigurationCompositionExample(); } - private static void BasicAddDbContextExample() + private static void BasicConfigureDbContextExample() { - Console.WriteLine("=== Basic AddDbContext Example ==="); + Console.WriteLine("=== Basic ConfigureDbContext Example ==="); - #region BasicAddDbContext + #region BasicConfigureDbContext var services = new ServiceCollection(); - // DbContext registration with configuration - services.AddDbContext(options => - options.UseInMemoryDatabase("BasicExample") - .EnableSensitiveDataLogging() + // Configure non-provider-specific options + services.ConfigureDbContext(options => + options.EnableSensitiveDataLogging() .EnableDetailedErrors()); + // Add the context with provider configuration + services.AddDbContext(options => + options.UseInMemoryDatabase("BasicExample")); + var serviceProvider = services.BuildServiceProvider(); #endregion using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); - Console.WriteLine($"Context configured successfully with provider: {context.Database.ProviderName}"); + Console.WriteLine($"Context configured with provider: {context.Database.ProviderName}"); + Console.WriteLine("ConfigureDbContext was called before AddDbContext"); Console.WriteLine(); } - private static void MultipleAddDbContextCallsExample() + private static void ReusableComponentExample() { - Console.WriteLine("=== Multiple AddDbContext Calls Example (EF Core 8.0 Behavior) ==="); + Console.WriteLine("=== Reusable Component Example ==="); - #region MultipleAddDbContextCalls + #region ReusableComponent var services = new ServiceCollection(); - // First configuration - will be overridden in EF Core 8.0 - services.AddDbContext(options => - options.UseInMemoryDatabase("FirstDatabase")); - - // Second configuration - this takes precedence (EF Core 8.0 behavior) - services.AddDbContext(options => - options.UseInMemoryDatabase("SecondDatabase") - .EnableSensitiveDataLogging()); + // Use the testing extension method + services.AddTestingConfiguration(); + + // Add the context with provider + services.AddDbContext(options => + options.UseInMemoryDatabase("TestDb")); var serviceProvider = services.BuildServiceProvider(); #endregion @@ -78,35 +97,29 @@ private static void MultipleAddDbContextCallsExample() using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); - Console.WriteLine($"Provider: {context.Database.ProviderName}"); - Console.WriteLine("Note: In EF Core 8.0, the second AddDbContext call takes precedence over the first one."); - Console.WriteLine("This is different from EF Core 7.0 and earlier where the first call would win."); + Console.WriteLine($"Context configured for testing with provider: {context.Database.ProviderName}"); + Console.WriteLine("Testing configuration added via extension method"); Console.WriteLine(); } - private static void ConditionalConfigurationExample() + private static void ConfigurationCompositionExample() { - Console.WriteLine("=== Conditional Configuration Example ==="); + Console.WriteLine("=== Configuration Composition Example ==="); - #region ConditionalConfiguration + #region ConfigurationComposition var services = new ServiceCollection(); - - // Mock environment and configuration services - var isDevelopment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development"; - - services.AddDbContext((serviceProvider, options) => - { - if (isDevelopment) - { - options.UseInMemoryDatabase("DevelopmentDatabase") - .EnableSensitiveDataLogging() - .EnableDetailedErrors(); - } - else - { - options.UseInMemoryDatabase("ProductionDatabase"); - } - }); + + // First: add logging + services.ConfigureDbContext(options => + options.LogTo(Console.WriteLine)); + + // Second: add the provider + services.AddDbContext(options => + options.UseInMemoryDatabase("CompositionExample")); + + // Third: add sensitive data logging + services.ConfigureDbContext(options => + options.EnableSensitiveDataLogging()); var serviceProvider = services.BuildServiceProvider(); #endregion @@ -114,8 +127,8 @@ private static void ConditionalConfigurationExample() using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); - Console.WriteLine($"Context configured for environment: {(isDevelopment ? "Development" : "Production")}"); - Console.WriteLine($"Provider: {context.Database.ProviderName}"); + Console.WriteLine($"Context configured with provider: {context.Database.ProviderName}"); + Console.WriteLine("All three configurations were composed together"); Console.WriteLine(); } } \ No newline at end of file From c6277c378be24ba031d4ef99906d94dd0fea4636 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:13:26 +0000 Subject: [PATCH 05/10] Refine ConfigureDbContext documentation based on review feedback Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../core/dbcontext-configuration/index.md | 101 +++++++----------- .../ConfigureDbContextSample.csproj | 3 +- .../ConfigureDbContextSample/Program.cs | 53 +++------ 3 files changed, 53 insertions(+), 104 deletions(-) diff --git a/entity-framework/core/dbcontext-configuration/index.md b/entity-framework/core/dbcontext-configuration/index.md index e451ef2fc2..4883ad46fe 100644 --- a/entity-framework/core/dbcontext-configuration/index.md +++ b/entity-framework/core/dbcontext-configuration/index.md @@ -94,67 +94,43 @@ Read further in this article to learn more about configuration options. See [Dep ## ConfigureDbContext for configuration composition -Starting with EF Core 9.0, you can use `ConfigureDbContext` to apply additional configuration to a `DbContext` either before or after the `AddDbContext` call. This is particularly useful for composing non-conflicting, non-provider-specific configuration in reusable components or tests. +Starting with EF Core 9.0, you can use to apply additional configuration to a `DbContext` either before or after the `AddDbContext` call. This is particularly useful for composing non-conflicting configuration in reusable components or tests. ### Basic ConfigureDbContext usage -`ConfigureDbContext` allows you to add configuration without replacing the entire provider configuration: +`ConfigureDbContext` allows you to add configuration in a reusable library or component without replacing the entire provider configuration: -```csharp -// In a reusable library or component -services.ConfigureDbContext(options => - options.EnableSensitiveDataLogging() - .EnableDetailedErrors()); - -// Later, in the application -services.AddDbContext(options => - options.UseSqlServer(connectionString)); -``` + +[!code-csharp[BasicConfigureDbContext](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=BasicConfigureDbContext)] -```csharp -// In a testing utility library -public static class TestingExtensions -{ - public static IServiceCollection AddTestingConfiguration( - this IServiceCollection services) - where TContext : DbContext - { - services.ConfigureDbContext(options => - options.EnableSensitiveDataLogging() - .EnableDetailedErrors() - .LogTo(Console.WriteLine)); - - return services; - } -} +### Provider-specific configuration without connection strings -// In your test -services.AddTestingConfiguration(); -services.AddDbContext(options => - options.UseInMemoryDatabase("TestDb")); -``` +To apply provider-specific configuration you can use provider-specific configuration methods without supplying the connection string. The SQL Server provider also includes `ConfigureSqlEngine` for this case. See [SQL Server-specific batching behavior](xref:core/providers/sql-server/misc#configuresqlengine) for more information. -### Provider-specific configuration without connection strings + +[!code-csharp[ProviderSpecificConfiguration](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=ProviderSpecificConfiguration)] ### ConfigureDbContext and AddDbContext precedence @@ -162,23 +138,26 @@ When both `ConfigureDbContext` and `AddDbContext` are used, or when multiple cal For non-conflicting options (like adding logging, interceptors, or other settings), all configurations are composed together: -```csharp -// First: add logging -services.ConfigureDbContext(options => - options.LogTo(Console.WriteLine)); + +[!code-csharp[ConfigurationComposition](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=ConfigurationComposition)] -// Result: All three configurations are applied -``` +For conflicting options, the last configuration wins. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information about this behavior change. -For conflicting options (like specifying different database providers), the last configuration wins. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information about this behavior change. +> [!WARNING] +> Configuring a different provider will not remove the previous provider configuration. This can lead to errors when creating the context. To completely replace the provider, you need to remove the context registration and re-add it, or create a new service collection. diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj index eeb276be74..861ef7c279 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj @@ -9,9 +9,8 @@ + - - \ No newline at end of file diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs index 2cbab58c7d..f234261656 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs @@ -1,8 +1,7 @@ using System; +using System.Linq; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; namespace ConfigureDbContextSample; @@ -24,29 +23,12 @@ public class Blog } #endregion -#region TestingExtensions -public static class TestingExtensions -{ - public static IServiceCollection AddTestingConfiguration( - this IServiceCollection services) - where TContext : DbContext - { - services.ConfigureDbContext(options => - options.EnableSensitiveDataLogging() - .EnableDetailedErrors() - .LogTo(Console.WriteLine)); - - return services; - } -} -#endregion - public class Program { public static void Main(string[] args) { BasicConfigureDbContextExample(); - ReusableComponentExample(); + ProviderSpecificConfigurationExample(); ConfigurationCompositionExample(); } @@ -57,12 +39,10 @@ private static void BasicConfigureDbContextExample() #region BasicConfigureDbContext var services = new ServiceCollection(); - // Configure non-provider-specific options services.ConfigureDbContext(options => options.EnableSensitiveDataLogging() .EnableDetailedErrors()); - // Add the context with provider configuration services.AddDbContext(options => options.UseInMemoryDatabase("BasicExample")); @@ -73,32 +53,27 @@ private static void BasicConfigureDbContextExample() var context = scope.ServiceProvider.GetRequiredService(); Console.WriteLine($"Context configured with provider: {context.Database.ProviderName}"); - Console.WriteLine("ConfigureDbContext was called before AddDbContext"); Console.WriteLine(); } - private static void ReusableComponentExample() + private static void ProviderSpecificConfigurationExample() { - Console.WriteLine("=== Reusable Component Example ==="); + Console.WriteLine("=== Provider-Specific Configuration Example ==="); - #region ReusableComponent + #region ProviderSpecificConfiguration var services = new ServiceCollection(); - // Use the testing extension method - services.AddTestingConfiguration(); - - // Add the context with provider - services.AddDbContext(options => - options.UseInMemoryDatabase("TestDb")); + services.ConfigureDbContext(options => + options.UseSqlServer(sqlOptions => + sqlOptions.EnableRetryOnFailure())); + + services.AddDbContext(options => + options.UseSqlServer("connectionString")); var serviceProvider = services.BuildServiceProvider(); #endregion - using var scope = serviceProvider.CreateScope(); - var context = scope.ServiceProvider.GetRequiredService(); - - Console.WriteLine($"Context configured for testing with provider: {context.Database.ProviderName}"); - Console.WriteLine("Testing configuration added via extension method"); + Console.WriteLine("Provider-specific configuration applied"); Console.WriteLine(); } @@ -109,15 +84,12 @@ private static void ConfigurationCompositionExample() #region ConfigurationComposition var services = new ServiceCollection(); - // First: add logging services.ConfigureDbContext(options => options.LogTo(Console.WriteLine)); - // Second: add the provider services.AddDbContext(options => options.UseInMemoryDatabase("CompositionExample")); - // Third: add sensitive data logging services.ConfigureDbContext(options => options.EnableSensitiveDataLogging()); @@ -128,7 +100,6 @@ private static void ConfigurationCompositionExample() var context = scope.ServiceProvider.GetRequiredService(); Console.WriteLine($"Context configured with provider: {context.Database.ProviderName}"); - Console.WriteLine("All three configurations were composed together"); Console.WriteLine(); } } \ No newline at end of file From e544d44c8cebcc10e8f9807135bc9357839cf9d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:30:12 +0000 Subject: [PATCH 06/10] Apply final review feedback - update ms.date, change WARNING to NOTE, remove BlogContext region, adjust endregion placement Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- entity-framework/core/dbcontext-configuration/index.md | 4 ++-- .../ConfiguringDbContext/ConfigureDbContextSample/Program.cs | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/entity-framework/core/dbcontext-configuration/index.md b/entity-framework/core/dbcontext-configuration/index.md index 4883ad46fe..74b463bd43 100644 --- a/entity-framework/core/dbcontext-configuration/index.md +++ b/entity-framework/core/dbcontext-configuration/index.md @@ -2,7 +2,7 @@ title: DbContext Lifetime, Configuration, and Initialization - EF Core description: Patterns for creating and managing DbContext instances with or without dependency injection author: SamMonoRT -ms.date: 11/07/2020 +ms.date: 09/30/2025 uid: core/dbcontext-configuration/index --- @@ -156,7 +156,7 @@ For non-conflicting options (like adding logging, interceptors, or other setting For conflicting options, the last configuration wins. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information about this behavior change. -> [!WARNING] +> [!NOTE] > Configuring a different provider will not remove the previous provider configuration. This can lead to errors when creating the context. To completely replace the provider, you need to remove the context registration and re-add it, or create a new service collection. diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs index f234261656..82ff36c69f 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs @@ -5,7 +5,6 @@ namespace ConfigureDbContextSample; -#region BlogContext public class BlogContext : DbContext { public BlogContext(DbContextOptions options) : base(options) @@ -21,7 +20,6 @@ public class Blog public required string Title { get; set; } public string? Content { get; set; } } -#endregion public class Program { @@ -48,7 +46,6 @@ private static void BasicConfigureDbContextExample() var serviceProvider = services.BuildServiceProvider(); #endregion - using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); @@ -72,7 +69,6 @@ private static void ProviderSpecificConfigurationExample() var serviceProvider = services.BuildServiceProvider(); #endregion - Console.WriteLine("Provider-specific configuration applied"); Console.WriteLine(); } @@ -95,7 +91,6 @@ private static void ConfigurationCompositionExample() var serviceProvider = services.BuildServiceProvider(); #endregion - using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); From 52ec51ec18e669a34f4e06c4d6a1c528b36771d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:37:53 +0000 Subject: [PATCH 07/10] Move endregion tags to exclude var serviceProvider line from code snippets Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../ConfigureDbContextSample/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs index 82ff36c69f..6fadb6ef9d 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs @@ -43,9 +43,9 @@ private static void BasicConfigureDbContextExample() services.AddDbContext(options => options.UseInMemoryDatabase("BasicExample")); + #endregion var serviceProvider = services.BuildServiceProvider(); - #endregion using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); @@ -66,9 +66,9 @@ private static void ProviderSpecificConfigurationExample() services.AddDbContext(options => options.UseSqlServer("connectionString")); + #endregion var serviceProvider = services.BuildServiceProvider(); - #endregion Console.WriteLine("Provider-specific configuration applied"); Console.WriteLine(); } @@ -88,9 +88,9 @@ private static void ConfigurationCompositionExample() services.ConfigureDbContext(options => options.EnableSensitiveDataLogging()); + #endregion var serviceProvider = services.BuildServiceProvider(); - #endregion using var scope = serviceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); From 1072ea37ed8e83722fe3cf1507bd8d2876e4ba28 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Sep 2025 21:57:37 +0000 Subject: [PATCH 08/10] Move ConfigureDbContext sample code to main project and remove separate sample directory Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../core/dbcontext-configuration/index.md | 6 +++--- .../Program.cs => ConfigureDbContextSample.cs} | 6 ++++-- .../ConfigureDbContextSample.csproj | 16 ---------------- .../ConfiguringDbContext.csproj | 5 ++++- 4 files changed, 11 insertions(+), 22 deletions(-) rename samples/core/Miscellaneous/ConfiguringDbContext/{ConfigureDbContextSample/Program.cs => ConfigureDbContextSample.cs} (97%) delete mode 100644 samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj diff --git a/entity-framework/core/dbcontext-configuration/index.md b/entity-framework/core/dbcontext-configuration/index.md index 74b463bd43..a0ce9cba32 100644 --- a/entity-framework/core/dbcontext-configuration/index.md +++ b/entity-framework/core/dbcontext-configuration/index.md @@ -112,7 +112,7 @@ Starting with EF Core 9.0, you can use -[!code-csharp[BasicConfigureDbContext](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=BasicConfigureDbContext)] +[!code-csharp[BasicConfigureDbContext](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs?name=BasicConfigureDbContext)] ### Provider-specific configuration without connection strings @@ -130,7 +130,7 @@ To apply provider-specific configuration you can use provider-specific configura var serviceProvider = services.BuildServiceProvider(); --> -[!code-csharp[ProviderSpecificConfiguration](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=ProviderSpecificConfiguration)] +[!code-csharp[ProviderSpecificConfiguration](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs?name=ProviderSpecificConfiguration)] ### ConfigureDbContext and AddDbContext precedence @@ -152,7 +152,7 @@ For non-conflicting options (like adding logging, interceptors, or other setting var serviceProvider = services.BuildServiceProvider(); --> -[!code-csharp[ConfigurationComposition](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs?name=ConfigurationComposition)] +[!code-csharp[ConfigurationComposition](../../../samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs?name=ConfigurationComposition)] For conflicting options, the last configuration wins. See [breaking changes in EF Core 8.0](xref:core/what-is-new/ef-core-8.0/breaking-changes#AddDbContext) for more information about this behavior change. diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs similarity index 97% rename from samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs rename to samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs index 6fadb6ef9d..9efb385cf9 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/Program.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs @@ -1,3 +1,5 @@ +#nullable enable + using System; using System.Linq; using Microsoft.EntityFrameworkCore; @@ -21,9 +23,9 @@ public class Blog public string? Content { get; set; } } -public class Program +public static class ConfigureDbContextExamples { - public static void Main(string[] args) + public static void Run() { BasicConfigureDbContextExample(); ProviderSpecificConfigurationExample(); diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj deleted file mode 100644 index 861ef7c279..0000000000 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample/ConfigureDbContextSample.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - Exe - net8.0 - enable - - - - - - - - - - \ No newline at end of file diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj b/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj index 5c4f6ce07a..0c34d65721 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj @@ -10,7 +10,10 @@ - + + + + From fc950c99e97938333f1365d5c41cc52aa37da0b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Sep 2025 23:50:00 +0000 Subject: [PATCH 09/10] Update all package references to version 9.0.0 and target framework to net9.0 Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../ConfiguringDbContext/ConfiguringDbContext.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj b/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj index 0c34d65721..a59c8ca8d1 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfiguringDbContext.csproj @@ -1,15 +1,15 @@  - net8.0 + net9.0 enable - - - + + + From ce6de19279049e4eb53de3b564e6117b60cdbba5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Sep 2025 23:53:30 +0000 Subject: [PATCH 10/10] Rename ConfigureDbContextExamples class to ConfigureDbContextSample Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../ConfiguringDbContext/ConfigureDbContextSample.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs index 9efb385cf9..71ad0c4b2e 100644 --- a/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs +++ b/samples/core/Miscellaneous/ConfiguringDbContext/ConfigureDbContextSample.cs @@ -23,7 +23,7 @@ public class Blog public string? Content { get; set; } } -public static class ConfigureDbContextExamples +public static class ConfigureDbContextSample { public static void Run() {