Search⌘ K
AI Features

Getting the Generated SQL

Explore how to output and examine the SQL statements generated by Entity Framework Core from your C# queries. This lesson helps you understand the translation of LINQ queries to SQL, including parameter usage and syntax differences between databases, enabling you to write more efficient data access code.

Analyzing generated SQL queries

We might wonder how well-written the SQL statements are generated from the C# queries we write. EF Core 5 introduced a quick and easy way to see the SQL generated:

Step 1: In the FilteredIncludes method, before using the foreach statement to enumerate the query, add a statement to output the generated SQL, as shown in ...