The return type for ExecuteSql should be int. You should use FromSql, then the issue could be fixed.
public int cmd2()
{
var appList = _context.Database.ExecuteSql($"select *from [HandyMansToolDb].dbo.Table2 ");
return appList;
}
public IActionResult cmd3()
{
var appList = _context.Table2Users.FromSql($"select *from [HandyMansToolDb].dbo.Table2 ");
return Ok(appList);
}
public IActionResult cmd4()
{
var appList = _context.Table2Users.FromSqlRaw($"select *from [HandyMansToolDb].dbo.Table2 ");
return Ok(appList);
}
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Jason Pan