CRUD operations using Stored Procedure

First Step :

Right click Employee and select Stored Procedure Mapping

Step 2 :

You can now see Mapping Details for Employee as follows

Step 3 : You can see the different functions here for Insert, Update and Delete. Now we will map each and every function with the required Stored procedure as follows

I will show for Insert Function the same way you can do for Update and Delete functions

Steep 4 : Mapping Insert Functions with properties

Step 5 : Mapping each property to the Parameters

Step 6 : Assign each and every parameter the you can have your Insert Function as follows

Like this do for Update and Delete Functions too, and save it.

Now we will look how to create functions for the mapped Stored Procedures

Inside the Model window right click select -> Add-> Function Import

Step A :

After this you can see the list of available Stored Procedures that you have include for the Model.

Step B :

Select the required Stored Procedure Name and give a Function Import Name, I will show for InsertEmployee in the same way you can do for Update and Delete. For Select I will show how to do

Step C :

Repeat (from Step A – Step C) the same for Update and Delete too..

When coming for Select follow as per Insert with the following changes, as it will return data from table we have to make it as Complex.

Get Column Information

Create Complex Type

Save the Model and now we will check whether this functions are imported or not through code.


entities.InsertData(Convert.ToInt16(txtEmpID.Text), txtEmployeeName.Text, txtAddress.Text);
         entities.updateEmp(Convert.ToInt16(ddleditEmpID.SelectedValue.ToString()), txtedtEmployeeName.Text, txtedtEmpAddress.Text);



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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s