Practice question from ASP.NET Core & Minimal APIs Foundations

Fill in the service lifetime that creates one instance per HTTP request:

builder.Services.Add____(DbContext);

Answer

Scoped

Explanation

Scoped lifetime creates one instance per HTTP request (per scope). This is perfect for DbContext because it tracks changes during a request and should be disposed after. Transient would create too many instances, and Singleton would cause threading issues.

More questions from ASP.NET with .NET 10