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

    Question

  • Hi,

    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?

     

    TNX!


    amazingwolf
    Friday, September 03, 2010 9:02 PM

Answers

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

    Thanks Kumar!


    amazingwolf
    • Marked as answer by amazingwolf Sunday, September 05, 2010 7:12 PM
    Sunday, September 05, 2010 7:12 PM

All replies

  • 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);

     

    Thanks

    Vishesh

    • Proposed as answer by Kumar Vishesh Sunday, September 05, 2010 12:15 PM
    Sunday, September 05, 2010 12:13 PM
  • 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!


    amazingwolf
    Sunday, September 05, 2010 6:47 PM
  • Found the problem - db user did not have execute permissions on stored procedure...

    Thanks Kumar!


    amazingwolf
    • Marked as answer by amazingwolf Sunday, September 05, 2010 7:12 PM
    Sunday, September 05, 2010 7:12 PM
  • This answer TOTALLY saved my day - thank you!

    Qkev

    Thursday, August 16, 2012 11:39 PM
  • 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.

    Thursday, June 20, 2013 5:04 AM