Categories
c# ef-core-2.1 entity-framework sql

Execute RAW SQL on DbContext in EF Core 2.1

I have researched this and always found examples like this:

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

The problem is, I don’t want to run my raw SQL on the Blogs table. Basically, I want to implement an interface like this:

bool ExecuteNonSafeSql(
string connectionString,
string sql);

Is there a way to do that with DbContext?