data-state-and-services

Primary docs: - https://learn.microsoft.com/aspnet/core/data/ - https://learn.microsoft.com/aspnet/core/fundamentals/dependency-injection - https://learn.microsoft.com/aspnet/core/fundamentals/http-requests - https://learn.microsoft.com/asp

Data, State, And Services

Primary docs:

Dependency Injection Defaults

EF Core And DbContext

Use EF Core for common relational data access patterns unless the repository already uses another data layer.

Default guidance:

Use IDbContextFactory<TContext> when the execution model is not request-scoped, such as:

Options And Configuration

Outbound HTTP

Use IHttpClientFactory for outbound HTTP calls.

Prefer:

Avoid manual new HttpClient() patterns scattered through request handlers.

App State

Use the smallest state mechanism that fits:

Do not treat session as the primary application data store.

Caching And State Boundaries