For the code
public object GetRawSqlResult(string request)
{
object result = ctx.Database.ExecuteSqlCommand(request);
return result;
}
I get this error for ExecuteSqlCommand
:
CS1061: 'DatabaseFacade' does not contain a definition for 'ExecuteSqlCommand' and no accessible extension method 'ExecuteSqlCommand' accepting a first argument of type 'DatabaseFacade' could be found (are you missing a using directive or an assembly type reference?)
There is a Database property in the Context class, but it does not give access to a direct SQL raw query (i.e., Context.Database).
The Microsoft help, Raw SQL Queries, does not tell how to do it without using a specific Context class.
I want a pure SQL command, and I do not want to pass through an entity. In hands, I only have the class name and want to verify the table exists into the database. I do not have any instance of it. There should be a way to just run a command against the database.
Just for additional information (there is no "ExecuteSqlCommand..."):