How to call a stored procedure using entity framework(edm)

First u need to create some database including tables and related stored procedures after completing this task we need to add that data base to our front end as entity framework for that we do some procedure. If u want that procedure please refer

When adding .edmx file we need to check tables and stored procedures as shown below

calling stored procedure using edm

after completion of .edmx file we need to add the available stored procedures in our .edmx to functions

for that first open modal browser and then open EntityContainer

then right clickon function imports and choose add function import as shown in below figure

We can get one window to select storedprocedure as follows

In that window we have different fields

1. function import name: this is the function name we will use in our front end to call stored procedure.

2. storedprocedurename: this is the storedprocedure name in our database and .edmx file we need to call

3. returns a collection of this will tell which type of output is coming from storedprocedure(we need to select this).

If we want to call that imported function

First create object for edm like

SRMModel.SRMBEntities ent = new SRMModel.SRMBEntities();

And call function like

ent.ForgotPWD();//if it don’t have any parameters to pass

if it have any input parameters call as follows

ent.ForgotPWD(UName, Qsn, Ans);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s