Skip to main content

What it flags

A C# EF Core query materializes rows into a list or array immediately before reading its count. The rule looks for a DbSet<T> declaration from Entity Framework Core.

How to review or fix

Use Count() or CountAsync() directly on the query so the database can return a count without transferring the rows.