0

I want exact solution like this question for code first.

We are using Entity Framework 6.0.0 and use code first (like this) to generate code from tables and stored procedures. This seems to work great, except that changes in stored procedures are not reflected when updating or refreshing the model. Adding a column to a table is reflected, but not adding a field to a stored procedure.

Sivamohan Reddy
  • 436
  • 1
  • 8
  • 26

1 Answers1

0

Actually EF doesn't support automatic update for stored procedures exactly as for tables. So here some manual work is required (this solution is for EF 6. I have not tried in other EF versions. It works nice):

  • Go to Model browser. StoredProc1 is the name of the stored procedure.
  • StoredProc1 will appear in 3 places:
    • 1st place: under complex types -> as StoredProc1_result
    • 2nd place: under function imports -> as StoredProc1
    • 3rd place: under Stored Procdures / Functions -> as StoredProc1

Delete all three from the model. Save the .edmx (by clicking in the window then ctrl+S). Then right-click and click update the model from database. Then add the updated stored procedure and save again.

It is still manual work, but it solves the problem.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
alaa_sayegh
  • 2,141
  • 4
  • 21
  • 37