Click here to Skip to main content
11,639,765 members (59,816 online)
Click here to Skip to main content

Tagged as

Using stored procedures in Entity Framework Model First Approach (Part II - Updating an existing Stored procedure)

, 15 Apr 2014 CPOL 3.6K 3
Rate this:
Please Sign up or sign in to vote.
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 can we go for updating it in Entity Framework so that the changes will reflect in the result. (changes include adding or r
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 can we go for 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)

Lets 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.

Here are the below 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):



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



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



STEP IV(Update the Function Import to get the new column):
           i) Click on the button 'Get Column Information' to get the information for the new               column added in stored procedure. 
           ii) Click on 'Update' button to update the Complex Type to add the new attribute.
           iii) Click on 'OK' button to apply and save the changes.



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




Hope this will be helpful for them who are 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)

Share

About the Author

SRS(The Coder)
Software Developer
India India
Having more than 5 years of development experience in various Microsoft Technologies like :-
ASP.Net, VB.Net, MVC, SQL Server, WCF, MS Commerce Server, Xamarin etc.

Also hands on experience on the client side coding with JavaScript/jQuery.
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

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150731.1 | Last Updated 16 Apr 2014
Article Copyright 2014 by SRS(The Coder)
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid