Call Stored Procedure from Entity Framework

First Create an edmx file.

Double click your edmx file and right click your model,Choose Function Import In the pop-up dialog,

Choose the SP that you want to import as a function.

Now you can use it through the database Context like below.

using (EntityContext ec = new EntityContext())


    ec.StoredProcdure here(Parameters);


You can also refer below articles for same.

For Database First / Model First you can set up EF to call the SPs automatically:

For Code First you have to call them manually:

Posted in |


Post a Comment