Repository: dotnet/efcore
File: src/EFCore/Extensions/EntityFrameworkServiceCollectionExtensions.cs (C#)

Code before:
    /// <remarks>
    ///     <para>
    ///         This overload aligns with the EF Core centralized configuration model
    ///         <see cref="ConfigureDbContext{TContext}(IServiceCollection, Action{DbContextOptionsBuilder}, ServiceLifetime)" />
    ///         and allows specifying a custom <paramref name="poolSize"/>.  
    ///         Options configured via <c>ConfigureDbContext&lt;TContext&gt;</c> are automatically used,
    ///         eliminating the need to repeat provider configuration.
    ///     </para>
    /// </remarks>
    /// <typeparam name="TContext">
    ///     The type of <see cref="DbContext" /> to be created by the factory.
    /// </typeparam>
    /// <param name="serviceCollection">
    ///     The <see cref="IServiceCollection" /> to which the services are added.
    /// </param>
    /// <param name="poolSize">
    ///     The maximum number of <typeparamref name="TContext" /> instances retained by the pool.
    ///     The default is 1024.
    /// </param>
    /// <returns>
    ///     The same <see cref="IServiceCollection" /> so that multiple calls can be chained.
    /// </returns>
    public static IServiceCollection AddPooledDbContextFactory
        <[DynamicallyAccessedMembers(DbContext.DynamicallyAccessedMemberTypes)] TContext>(
            this IServiceCollection serviceCollection,
            int poolSize)
        where TContext : DbContext
        => AddPooledDbContextFactory<TContext>(
            serviceCollection,
            static (_, __) => { },
            poolSize);


    /// <summary>
    ///     Configures the given context type in the <see cref="IServiceCollection" />.
    /// </summary>
    /// <remarks>
    ///     <para>
    ///         <see cref="AddDbContext{TContext}(IServiceCollection,Action{DbContextOptionsBuilder},ServiceLifetime,ServiceLifetime)" />,
    ///         <see cref="AddDbContextPool{TContext}(IServiceCollection,Action{DbContextOptionsBuilder},int)" />,
    ///         <see cref="AddDbContextFactory{TContext, TFactory}(IServiceCollection,Action{DbContextOptionsBuilder}?,ServiceLifetime)" /> or
    ///         <see cref="AddPooledDbContextFactory{TContext}(IServiceCollection,Action{DbContextOptionsBuilder},int)" />
    ///         must also be called for the specified configuration to take effect.
    ///         Calling this method after any of the above will ovewrite conflicting configuration.
    ///         For non-pooled contexts <see cref="DbContext.OnConfiguring" /> configuration will be applied
    ///         in addition to configuration performed here.
    ///     </para>
    ///     <para>
    ///         This method can be invoked multiple times and the configuration will be applied in the given order.
    ///     </para>
    ///     <para>

Review comment (suggestion):
```suggestion
            int poolSize = DbContextPool<DbContext>.DefaultPoolSize)
```

and remove the other overload

Code after:
    /// </returns>
    public static IServiceCollection AddPooledDbContextFactory
        <[DynamicallyAccessedMembers(DbContext.DynamicallyAccessedMemberTypes)] TContext>(
            this IServiceCollection serviceCollection,
            int poolSize = DbContextPool<DbContext>.DefaultPoolSize)
        where TContext : DbContext
        => AddPooledDbContextFactory<TContext>(
            serviceCollection,
            static (_, __) => { },
            poolSize);

    /// <summary>
    ///     Configures the given context type in the <see cref="IServiceCollection" />.
    /// </summary>
    /// <remarks>
    ///     <para>
    ///         <see cref="AddDbContext{TContext}(IServiceCollection,Action{DbContextOptionsBuilder},ServiceLifetime,ServiceLifetime)" />,
    ///         <see cref="AddDbContextPool{TContext}(IServiceCollection,Action{DbContextOptionsBuilder},int)" />,
    ///         <see cref="AddDbContextFactory{TContext, TFactory}(IServiceCollection,Action{DbContextOptionsBuilder}?,ServiceLifetime)" /> or
    ///         <see cref="AddPooledDbContextFactory{TContext}(IServiceCollection,Action{DbContextOptionsBuilder},int)" />
    ///         must also be called for the specified configuration to take effect.
    ///         Calling this method after any of the above will ovewrite conflicting configuration.
    ///         For non-pooled contexts <see cref="DbContext.OnConfiguring" /> configuration will be applied
    ///         in addition to configuration performed here.
    ///     </para>
    ///     <para>
    ///         This method can be invoked multiple times and the configuration will be applied in the given order.
    ///     </para>
    ///     <para>
    ///         See <see href="https://aka.ms/efcore-docs-di">Using DbContext with dependency injection</see> for more information and examples.
    ///     </para>
    /// </remarks>
    /// <typeparam name="TContext">The type of context to be registered.</typeparam>
    /// <param name="serviceCollection">The <see cref="IServiceCollection" /> to add services to.</param>
    /// <param name="optionsAction">An action to configure the <see cref="DbContextOptions" /> for the context.</param>
    /// <param name="optionsLifetime">
    ///     The lifetime with which the <see cref="DbContextOptions" /> service will be registered in the container.
    /// </param>
    /// <returns>The same service collection so that multiple calls can be chained.</returns>
    public static IServiceCollection ConfigureDbContext
        <[DynamicallyAccessedMembers(DbContext.DynamicallyAccessedMemberTypes)] TContext>(
            this IServiceCollection serviceCollection,
            Action<DbContextOptionsBuilder> optionsAction,
            ServiceLifetime optionsLifetime = ServiceLifetime.Singleton)
        where TContext : DbContext
        => ConfigureDbContext<TContext>(serviceCollection, (_, b) => optionsAction(b), optionsLifetime);

    /// <summary>
    ///     Configures the given context type in the <see cref="IServiceCollection" />.
    /// </summary>
    /// <remarks>