> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# csharp-ef-query-in-loop

> An EF Core DbSet query executes for each loop key.

## What it flags

A terminal operation on an Entity Framework Core DbSet query inside a `foreach` loop where the query uses the current iteration value.

## How to review or fix

Consider loading the matching keys in one query. Preserve ordering and any explicit behavior for missing rows.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.