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?
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);
- Proposed as answer by Kumar Vishesh Sunday, September 05, 2010 12:15 PM
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!
If everything else fails try this.
In the Update wizard of Update Model from Database, Try unchecking the options (1) Pluralize or singularize generated object names, (2) Include foreign key columns in the model, (3) Import selected stored procedures and functions into the entity model. Now you may be able to see the Store Procedure appearing in Model Browser.