How to use native queries with DBContext
? If I run the code, this give me exception. Why and what to do to run native query when using DBContext
?
AcademyEntities context = new AcademyEntities();
string nativeSQLQuery =
"SELECT * " +
"FROM dbo.Employees " +
"WHERE FirstName='{0}'";
string name = "Guy";
var emp = context.Departments.SqlQuery(nativeSQLQuery, name);
foreach (var item in emp)
{
}