Export (0) Print
Expand All

How to: Import a Stored Procedure

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This topic describes how to use the ADO.NET Entity Data Model Designer (Entity Designer) to import a stored procedure.

When a stored procedure is added to a conceptual model, it is called a function import. Adding a function import allows you to call the corresponding stored procedure from your application code. A function import can return collections of simple types, EntityTypes, or ComplexTypes, or no value.

Bb896231.note(en-us,VS.110).gifNote:
The insert, update, and delete operations of an entity type can be mapped to stored procedures. For more information, see How to: Map Modification Functions to Stored Procedures.

When the Entity Data Model Wizard generates an .edmx file from a database, it creates entries in the storage model for each stored procedure in the database. Corresponding entries are added to the conceptual model when function imports are created.

The procedure below describes how to create a function import. For information about calling a function import from application code, see How to: Execute a Query Using a Stored Procedure with In and Out Parameters and Walkthrough: Retrieving Entity Types with a Stored Procedure.

To create a function import

  1. Do one of the following from the Model Browser:

    • Open the Stored Procedures folder (in the storage model information) and double-click a stored procedure that does not have a corresponding function import.

    - OR -

    • Right-click the Function Imports folder (in the EntityContainer node of the conceptual model information) and then select Add Function Import.

    The Add Function Import dialog box appears.

  2. Fill in the settings for the new function import.

    • Specify the stored procedure for which you are creating a function import in the Stored Procedure Name field. This field is a drop-down list that displays all the stored procedures in the storage model. If the desired stored procedure is not available, you may need to update your storage model. For more information, see How to: Update an .edmx File when the Database Changes.

    • Specify the name of the function import in the Function Import Name field.

    • Specify one of the four basic return types: None, Scalars, Complex, or Entities, and select the specific return type from the available drop-down list. If you choose Complex, the Entity Designer can create a new complex type with properties that correspond to the columns returned by the stored procedure.

    1. Click Get Column Information to retrieve column information.

    2. Click Create New Complex Type.

    3. Edit the name of the complex type in the Complex drop-down list.

      When you click OK, a new complex type is added to the conceptual model and the return type of the function import is set to this new type.

      Bb896231.note(en-us,VS.110).gifNote:
      If you have changed the definition for your stored procedure in the storage model, you can automatically update the complex type it returns by clicking Update.

    Bb896231.note(en-us,VS.110).gifNote:
    If your application targets the .NET Framework 3.5 SP1, complex types are not supported as a return type for function imports.

  3. Click OK.

    The FunctionImport entry is created in the conceptual model. For more information, see FunctionImport Element (CSDL).

See Also

Concepts

Entity Data Model Designer

Other Resources

Tasks

Show:
© 2014 Microsoft