none
Adding Stored Procedure to EDMX RRS feed

  • Question

  • I am trying to add a stored procedure to EDMX model. It goes through the entire sequence of steps successfully and I can see the stored procedure name under "Function Imports" node in EDMXModel.

    But I cannot invoke the stored procedure using database context object programmatically. Intellisense does not show me the stored procedure name nor can I see it in the designer mode of EDMX file. Am I supposed to see this stored procedure in the designer mode similar to tables and views?

    I am using Entity Framework 3.5 in Visual Studio 2012.

    Thanks

    Friday, April 18, 2014 9:39 PM

Answers

  • Hi,

    >>How will I know which version of Entity Framework am I using?

    If your project target is .NET Framework 3.5, then it should be Entity Framework 3.5 since it will just let you select the 3.5 version as:

    If your project target is .NET 4 or higher, it will have a reference for EntityFramework.Dll, you can check the version of the dll as:

    >>Do you think my Visual Studio 2012 installation is missing some updates? Since I installed Visual Studio 2012, my windows updates for Office 2013 32-edition always fail.

    I am not sure whether it is missing some updates. You can have a try to repair it.

    And please also try to use Entity Framework 5 with your VS to check whether it could import the SP, since EF 5, the SP is supported better.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 22, 2014 6:17 AM
    Moderator

All replies

  • Hello,

    >>Am I supposed to see this stored procedure in the designer mode similar to tables and views?

    No, it does not need. For it, I made an example:

    My SP:

    CREATE PROCEDURE [dbo].[ProGetOrderName]
    
    AS
    
                    select * from [Order]
    
    RETURN 0
    

    My code calling the SP, it returns all data in the Order table:

    DFDBEntities db = new DFDBEntities();
    
    var result = db.ProGetOrderName();
    

    The steps for importing SP to model:

    Steps for editing the SP and calling it in project:

    If the SP is successfully imported, in the ModelXXX.Designer.cs file, it will be shown as below in the context class:

    public global::System.Data.Objects.ObjectResult<Order> ProGetOrderName()
    
            {
    
                return base.ExecuteFunction<Order>("ProGetOrderName");
    
            }
    

    Please check whether there is a function whose name is your SPs.

    If this does not work for you, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 21, 2014 2:31 AM
    Moderator
  • How will I know which version of Entity Framework am I using?

    The steps that you showed me are exactly what I did but cannot see it ModelXXX.Designer.cs file. I can see the stored procedure as a subnode under

    XXXModel and XXXModel.Store nodes in the model browser.

    Do you think my Visual Studio 2012 installation is missing some updates? Since I installed Visual Studio 2012, my windows updates for Office 2013 32-edition always fail.


    • Edited by diffident Monday, April 21, 2014 2:54 PM
    Monday, April 21, 2014 2:51 PM
  • Hi,

    >>How will I know which version of Entity Framework am I using?

    If your project target is .NET Framework 3.5, then it should be Entity Framework 3.5 since it will just let you select the 3.5 version as:

    If your project target is .NET 4 or higher, it will have a reference for EntityFramework.Dll, you can check the version of the dll as:

    >>Do you think my Visual Studio 2012 installation is missing some updates? Since I installed Visual Studio 2012, my windows updates for Office 2013 32-edition always fail.

    I am not sure whether it is missing some updates. You can have a try to repair it.

    And please also try to use Entity Framework 5 with your VS to check whether it could import the SP, since EF 5, the SP is supported better.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 22, 2014 6:17 AM
    Moderator