I migrate my application to ASP.NET MVC Core and Entity Framework Core and i found problem. I have raw SQL query to entity like this
var rawSQL = dbContext.Database.SqlQuery<SomeModel>("Raw SQL Query").ToList();
But there is no
context.Database. Do you have solution for this problem?
Make sure you add
because there is an extension method you could use.
var rawSQL = dbContext.SomeModels.FromSql("your SQL");
Even better, instead using raw SQL (at risk of SQL injections attacks) this FromSql method allows you to use parameterized queries like:
dbContext.SomeModels.FromSql("SELECT * FROM dbo.Blogs WHERE Name = @p0", blogName);