I need to execute SQL Command in MS SQL, which is already connected via EF Core 6.0.6.
First thing I found is: Execute RAW SQL on DbContext in EF Core 2.1
So I tried this:
db.Database.Query<Question>("COMMAND");
But it says that DatabaseFacade does not contain the Query<T>() method. Same thing with these ones:
db.Query<Question>("COMMAND");
db.Database.ExecuteSqlCommand("COMMAND");
db.Database.SqlQuery("COMMAND");
db.Database.GetDbConnection();
A little explanation:
dbis an instance of theApplicationDbContextclass which inherits fromIdentityDbContextfrom theMicrosoft.AspNetCore.Identity.EntityFrameworkCorepackageQuestionis my class, instances of which are stored in theQuestionstable in my database
So my main question is: Is there a way of executing raw SQL in EF Core 6.0.6?
I would be very grateful for any materials or tips in this matter.