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

Code before:
    {
        Check.NotNull(optionsAction);

        AddPoolingOptions<TContext>(serviceCollection, optionsAction, poolSize);

        serviceCollection.TryAddSingleton<IDbContextPool<TContext>, DbContextPool<TContext>>();
        serviceCollection.TryAddSingleton<IDbContextFactory<TContext>>(sp
            => new PooledDbContextFactory<TContext>(sp.GetRequiredService<IDbContextPool<TContext>>()));
        serviceCollection.TryAddScoped<TContext>(sp => sp.GetRequiredService<IDbContextFactory<TContext>>().CreateDbContext());

        return serviceCollection;
    }

    /// <summary>
    ///     Registers a pooled <see cref="IDbContextFactory{TContext}" /> in the
    ///     <see cref="IServiceCollection" /> for creating instances of the specified
    ///     <see cref="DbContext" /> type.
    /// </summary>
    /// <remarks>
    ///     <para>
    ///         This parameterless overload aligns the pooled factory with the centralized
    ///         configuration model introduced by
    ///         <see cref="ConfigureDbContext{TContext}(IServiceCollection, Action{DbContextOptionsBuilder}, ServiceLifetime)"/>
    ///         When used together, options (including the database provider) configured in
    ///         <c>ConfigureDbContext&lt;TContext&gt;</c> automatically flow into the pooled factory,
    ///         avoiding redundant configuration lambdas.
    ///     </para>
    ///     <para>
    ///         See <see href="https://aka.ms/efcore-docs-di">Using DbContext with dependency injection</see>,
    ///         <see href="https://aka.ms/efcore-docs-dbcontext-factory">Using DbContext factories</see>, and
    ///         <see href="https://aka.ms/efcore-docs-dbcontext-pooling">Using DbContext pooling</see>
    ///         for more information and examples.
    ///     </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>
    /// <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)
        where TContext : DbContext
        => AddPooledDbContextFactory<TContext>(
            serviceCollection,
            static (_, __) => { },
            DbContextPool<DbContext>.DefaultPoolSize);

Review comment (security):
The `<remarks>` section should include additional standard documentation paragraphs similar to existing overloads. Looking at lines 977-1001, the existing overloads document: 1) When to use factory vs direct registration (Blazor scenarios), 2) DI vs. non-DI usage, and 3) Threading constraints. These are important for API consistency and completeness.
```suggestion
    ///     </para>
    ///     <para>
    ///         Use <see cref="AddPooledDbContextFactory{TContext}(IServiceCollection, int)" /> when you need to create
    ///         <see cref="DbContext" /> instances in scenarios where dependency injection cannot be used, such as in Blazor
    ///         applications or background services. For typical ASP.NET Core applications where a single context instance is
    ///         used per request, consider using <see cref="AddDbContext{TContext}(IServiceCollection, Action{DbContextOptionsBuilder}?, ServiceLifetime, ServiceLifetime)" />
    ///         instead.
    ///     </para>
    ///     <para>
    ///         For applications that don't use dependency injection, consider creating <see cref="DbContext" /> instances
    ///         directly with its constructor. The <see cref="DbContext.OnConfiguring" /> method can then be overridden to
    ///         configure a connection string and other options.
    ///     </para>
    ///     <para>
    ///         Entity Framework Core does not support multiple parallel operations being run on the same <see cref="DbContext" />
    ///         instance. This includes both parallel execution of async queries and any explicit concurrent use from multiple threads.
    ///         Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute
    ///         in parallel. See <see href="https://aka.ms/efcore-docs-threading">Avoiding DbContext threading issues</see> for more information
    ///         and examples.
    ///     </para>
    ///     <para>
    ///         See <see href="https://aka.ms/efcore-docs-di">Using DbContext with dependency injection</see> for more information and examples.
    ///     </para>
```

Code after:
    {
        Check.NotNull(optionsAction);

        AddPoolingOptions<TContext>(serviceCollection, optionsAction, poolSize);

        serviceCollection.TryAddSingleton<IDbContextPool<TContext>, DbContextPool<TContext>>();
        serviceCollection.TryAddSingleton<IDbContextFactory<TContext>>(sp
            => new PooledDbContextFactory<TContext>(sp.GetRequiredService<IDbContextPool<TContext>>()));
        serviceCollection.TryAddScoped<TContext>(sp => sp.GetRequiredService<IDbContextFactory<TContext>>().CreateDbContext());

        return serviceCollection;
    }

    /// <summary>
    ///     Registers a pooled <see cref="IDbContextFactory{TContext}" /> in the
    ///     <see cref="IServiceCollection" /> for creating instances of the specified
    ///     <see cref="DbContext" /> type, using a custom pool size.
    /// </summary>
    /// <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>
    ///     <para>
    ///         Use this method when using dependency injection in your application, such as with ASP.NET Core.
    ///         For applications that don't use dependency injection, consider creating <see cref="DbContext" />
    ///         instances directly with its constructor. The <see cref="DbContext.OnConfiguring" /> method can then be
    ///         overridden to configure a connection string and other options.
    ///     </para>
    ///     <para>
    ///         Entity Framework Core does not support multiple parallel operations being run on the same <see cref="DbContext" />
    ///         instance. This includes both parallel execution of async queries and any explicit concurrent use from multiple threads.
    ///         Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute
    ///         in parallel. See <see href="https://aka.ms/efcore-docs-threading">Avoiding DbContext threading issues</see> for more information
    ///         and examples.
    ///     </para>
    ///     <para>
    ///         See <see href="https://aka.ms/efcore-docs-di">Using DbContext with dependency injection</see>,
    ///         <see href="https://aka.ms/efcore-docs-dbcontext-factory">Using DbContext factories</see>, and
    ///         <see href="https://aka.ms/efcore-docs-dbcontext-pooling">Using DbContext pooling</see>
    ///         for more information and examples.
    ///     </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.