Should you use Include or a projection (Select) in EF Core?
Quick Answer
Include loads full related entities and tracks them — right when you need to modify the graph. A projection (Select into a DTO) pulls only the columns you list, across joins, with no tracking — right for read-only screens and API responses, and usually faster.
It depends on whether I'm going to change the data. If I need to load an order, modify its lines and save, I use Include so I get the real tracked entities. If it's a read — a list screen, an API response — I project into a DTO with Select, because EF then only fetches the exact columns I named, joins as needed, and doesn't track anything, which is faster and lighter. And if I ever Include several collections at once I turn on AsSplitQuery to avoid the row explosion from the cartesian join.
Include(o => o.Lines).ThenInclude(l => l.Product)— you get wholeOrder,Line,Productentities; use for edit scenarios.Select(o => new OrderDto { o.Id, LineCount = o.Lines.Count, Total = o.Lines.Sum(l => l.Price) })— one query, minimal columns, no change tracker.- Multiple collection
Includes cause a cartesian explosion — addAsSplitQuery(). - Rule: reading → project; writing → include.