엔티티 프레임 워크 5와 함께 asp.net mvc 3을 사용하고 있습니다. 내 .edmx 파일 &은 linq 또는 SP를 사용하여 데이터베이스와 상호 작용할 수 있지만 일부 원시 SQL 문을 실행하려고합니다. 나는 이런 식으로 노력하고있다 :엔티티 프레임 워크에서 원시 SQL 쿼리를 실행하는 방법은 무엇입니까?
Using(var ctx=new HREntities())
{
ctx.Database.ExecuteSqlCommand("insert into Employees values {0}, {1}", model.EMPLOYEEID, model.EMPLOYEENAME);
ctx.SaveChanges();
}
이런 식으로 SQL 쿼리를 실행할 수 있습니까? 감사.
http://stackoverflow.com/questions/915329/is-it-possible-to-run-native-sql-with-entity-framework – Satpal
http://stackoverflow.com/questions/16807334/execute-raw-sql-query-in-asp-net-mvc-database-first-mode/29147592#29147592 에서 내 대답을 살펴볼 수도 있습니다. [1] : http://stackoverflow.com/questions/16807334/execute-raw-sql-query-in-asp-net-mvc-database-first-mode/29147592#29147592 –