I am writing a program which gets data from a database using an entity datamodel (database-first approach) with a stored procedure. I am a beginner to ASP.NET MVC, can anyone answer.... I bind database tables and stored procedure also,but how can i bind stored procedure to controller method to insert data(database first approach am using)
Asked
Active
Viewed 679 times
1 Answers
0
If you are using EF db-first and you want to call your stored procedure from controller's action, first of all, you should create a EF dataContext instance inside your action:
public ActionResult MyAction(){
using(var ctx = new MyDbEntities()){
ctx.MyMappedProcedure(arg1, arg2);
}
//todo: manipulate your data and/or return result from controller
}

n.prokhorov
- 930
- 7
- 13