Running stored procedures with MS Entity Framework

Yener_Alemdaroglu used Ask the Experts™
Entity Framework is able to run stored procedures according to white papers. There seems to be a difficult way to do this by editing xml files. Is there an easier way than this? Can you give examples please?

Thank you...
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Technical Architect
To call a store procedure in Entity Framework you no need to edit XML files.

1. Right Click on entity Model
2. Select "Update Model from database"
3. Select the stored procedure u want to call and click ok and close the window
4. Right Click on entity Model
5. Select "Model Browser"
6. Expand the Entity Created by you
7. Right Click on "Function Imports"
8. Selecte your "stored procedure" from the drop down and give a "Function Name" and select any return type.

In the code, your entity model instance will have method which is same our Function name which we created in above step 8.

<entityinstance>.<function name>()  //will fire your stored procedure


This is a good and complete answer. Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial