Search code examples
entity-framework-coreef-core-6.0

Use EF Core 6 "dotnet ef dbcontext scaffold " generates context, but there is no ExecuteSqlCommand method


I use

dotnet ef dbcontext scaffold

to get a DbContext; add, update, and delete are all OK.

But I want use raw SQL queries, like this:

var blogs = context.Blogs.FromSqlRaw("SELECT \* FROM dbo.Blogs").ToList();

but my DbContext doesn't have this FromSqlRaw method

How to correct this error?


Solution

  • Sounds like you're missing a using.

    using Microsoft.EntityFrameworkCore;