Click here to Skip to main content
15,891,253 members
Articles / All Topics

Using Stored Procedures in Entity Framework Model First Approach (Part II - Updating an Existing Stored Procedure)

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
15 Apr 2014CPOL1 min read 6.7K   3  
In this article, I will explain if any changes made to a stored procedure in database, then how to go about updating it in Entity Framework so that the changes will reflect in the result.

I have already explained how to add a new stored procedure to Entity Framework, now in this article I will explain if any changes made to a stored procedure in database, then how to go about updating it in Entity Framework so that the changes will reflect in the result (changes include adding or removing the columns in stored procedure mainly).

Let's take the same stored procedure which we already added in the first part of this article named as 'GetAllPersons' which was having only 4 columns previously like ID, Name, Age, DOB and now I want to add a new column named as 'Department' which should also reflect in the result set.

Below are the steps we may follow to get this work as expected.

STEP I (Refresh the Model to get the new column added in the Person table in database):

Image 1

STEP II (Refresh the model to get the new column returned by the stored procedure):

Image 2

STEP III (Go for the EDIT mode of the Function import already in use):

Image 3

STEP IV (Update the Function Import to get the new column):

  1. Click on the button 'Get Column Information' to get the information for the new column added in stored procedure.
  2. Click on 'Update' button to update the Complex Type to add the new attribute.
  3. Click on 'OK' button to apply and save the changes.

Image 4

STEP V (Run the custom tool for reflecting changes in model classes):

Image 5

Hope this will be helpful for them who have already started with using Entity Framework and just looking for a guide in using stored procedure in Entity Framework.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
Having more than 9 years of development experience in various Microsoft Technologies like :-
ASP.Net, MVC, SQL Server, WCF, MS Commerce Server, Xamarin etc.

Also hands on experience on the client side coding with JavaScript/jQuery and framework like AngularJS. Worked with third party ASP.net controls like Telerik and DevExpress as well.

Very much interested in Microsoft technologies to explore and implement. Now started to helping coders who really need me.

My Blog


Microsoft Technology Master

Programming Communities


JS Fiddle | Stack Overflow

Awards


Microsoft MCTS Certification in ASP.Net 4.0

Comments and Discussions

 
-- There are no messages in this forum --