Using Stored Procedures to Populate Custom Entites RRS feed

  • Question

  • Briefly:

    I'm coming up with an error trying to access my custom entities in EF 5.3. 

    Longer version:

    I have a simple project that exposes 7 custom entities.  I have created Stored Procedures that have been set up as Function Imports so I can populate those entities from a database.  We are using this approach to abstract the underlying database structure from the end-consumer of the data (application, individual, etc).  These custom entities each represent multiple tables in the actual database.

    I read an article by Julie Lerman (Stored Procedures in the Entity Framework) that indicates you can map an entity to a Stored Procedure as long as that stored procedure is imported as a "Function Import" and that function import tied to an entity that can accept exactly the structure of the data that is returned by the Stored Procedure.

    While the code compiles fine and looks like it should work, every time I try and access the entity, it gives me a 2026 error (essentially missing mapping).

    I'm more than happy to provide code examples, but was hoping someone could point me in the right direction so I can see what I'm missing.

    Thanks in advance.


    Treo 700wx guy

    • Edited by Larrycwpc Thursday, June 27, 2013 9:46 PM
    Thursday, June 27, 2013 9:03 PM


  • Hi Larry;

    When you did the function import wizard in the section of the wizard marked "Returns a Collection Of" did you select "Entities" and from the combo box did you select the class that matches the data being returned from the stored procedure, same number of columns, having the associated data type, and the fields in the class having public properties matching the columns names?

    Make sure that the class you created to received the return from the stored procedure is in the same name space as the model.

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Chester Hong Monday, July 8, 2013 5:15 PM
    Friday, June 28, 2013 1:27 AM