I would like to add something to Sudhanshu Singh's answer: it works very well, but if you have more complex structures, combine it with a table declaration.
I have successfully used the following (put it at the very beginning of the stored procedure):
CREATE PROCEDURE [EY].[MyStoredProc] AS BEGIN SET NOCOUNT ON; IF (1=0) BEGIN SET FMTONLY OFF BEGIN
Note that 1=0
ensures that it will never be executed, but EF subtracts the structure from it.
After you saved the stored procedure, open the EDMX file in Visual Studio, update the data model, go to the Entity Frameworks model browser. In the model’s browser, find your stored procedure, open the “Edit Import Function” dialog box, select “Returns the collection ... Complex”, then click the “Get Column Information” button.
It should display the structure defined above. If so, click Create New Complex Type, and it will create one with the name of the stored procedure, for example. "MyStoredProc_Result" (added by "_Result").
Now you can select it in the "Returns collection ... Complex" drop-down list in the same dialog box.
Whenever you need to update something, first update the SP, then you can return to the "Edit Import Function" dialog box and click the "Update" button (you do not need to recreate everything from scratch).
Matt Aug 29 '14 at 9:04 on 2014-08-29 09:04
source share