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.

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.