Home » .Net Framework

Entity framework doens't show my stored procedure on "Update model from database"


Using VS 2010 and sql server 2005 express edition, i have created an EF model and imported some table into it using the wizard.

I have written a stored procedure in the same database and opened the  "Update model from database" wizard - but for some reason, my SP is not there.

I have restarted VS and SQL server, and it didn't do the trick.

finally, i downloaded anklab sql profiler and started a trace, found the query the EF wizard is running to get the SP names from the DB - and when I run it in the sql server management studio express - I can see my SP name!

I don't really know what i'm doing wrong. can someone please help me?




3 Answers Found


Answer 1

Hi amazingwolf,

Entity framework  will not show  your stored  procedure untill you map it to one of your database  entities or custom entities.

To do this, go to the model  browser, select your stored procedure-->right click-->Create function import and select one of the entities as the return types.

Save it and then you will be able to do something like this in your code:

ObjectResult<EntityName> entityRecords = objectContext.StoredProcedure(param1, param2);





Answer 2

Hi Kumar,


I opened the model  browser, but under "Stored procedures" there is no SP.

I have tried to click"Function Imports" and search for my SP there - but the drop down of "stored procedure  name" does not contain it.


What is the way to "tell" the model about my SP?...

I have googled this, but no luck yet.


Thank you for your help!


Answer 3

Found the problem - db user did not have execute permissions on stored  procedure...

Thanks Kumar!



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure