Can you add a stored procedure into an Entity Framework model (
I just did it in Visual Studio 2010, like this (except my stored procedure is now off the Add tab and is in the Refresh tab)
My stored procedure is a simple
SELECT statement, taking 1 parameter.
VS2010 seems to have added it into the Model, but I wonder where it is and how I can use it?
I can't see it anywhere in the diagram nor in
You part the way there. It's a bit of a hidden process and multi-stepped. You have to include the Stored Procedures in your model by selecting them in the menu you have shown above.
Once you have done that you want to view the 'Model Browser'
Then in the Model Browser, find the Model Store (This will have folders like 'Tables / Views'). Right click on your Stored Procedure and select 'Add Function Import'.
Once you have done this, you can map the Entities you will get back from your SP.
You will then be able to access your entities via your Context in code, in a strongly typed way. Hope that helps.
Complement for previous answer:
If need, not an entity but juste create a complex type (you can create it in complex type folder in model explorer) and associate it to your stored procedure if your returning dataobject doesn't match with a table of your DB, example: