Sitemap

Member-only story

11 No-Nonsense EF Core Raw SQL Tricks I Use When LINQ Starts Acting Cute (.NET 10)

5 min readJan 3, 2026

Press enter or click to view image in full size

If You want the full source code Click :Here

EF Core is like that friend who insists they can cook anything… until you ask for a spicy, database-specific dish with a CTE, a window function, and a weird hint to the query planner.

That’s when Raw SQL becomes your escape hatch.

In .NET 10 projects you’ll still use the same EF Core raw SQL patterns you’ve seen in recent EF Core versions:

  • Query with FromSqlRaw / FromSqlInterpolated
  • Execute commands with ExecuteSqlRaw / ExecuteSqlInterpolated
  • Project to non-entity types with Database.SqlQueryRaw<T> / Database.SqlQuery<T> (when available in your EF Core version)

I can’t verify any brand-new EF Core 10 API changes from here, so I’ll stick to the stable, widely-used surface area that works across modern EF Core.

1) When Raw SQL is the right tool (and when it’s just you panicking)

Use raw SQL when you need:

  1. CTEs, window functions, hints, vendor-specific functions
  2. Performance for a query LINQ can’t express cleanly

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web
Already have an account? Sign in

No responses yet

Unknown user

Write a response