This documentation is archived and is not being maintained.

FunctionImport Element (CSDL)

The FunctionImport element in conceptual schema definition language (CSDL) represents a function that is defined in the data source but available to objects through the conceptual model. For example, a Function element in the storage model can be used to represent a stored procedure in a database. A FunctionImport element in the conceptual model represents the corresponding function in an Entity Framework application and is mapped to the storage model function by using the FunctionImportMapping element. When the function is called in the application, the corresponding stored procedure is executed in the database.

A common language runtime (CLR) method can be generated for an Entity Framework application based on a FunctionImport element. For more information, see Generated Code Overview (Entity Data Model Designer) and How to: Use EdmGen.exe to Generate Object-Layer Code.

The FunctionImport element can have the following child elements (in the order listed):

One Parameter element should be defined for each parameter that the function accepts.

Applicable Attributes

The table below describes the attributes that can be applied to the FunctionImport element.

Attribute Name Is Required Value



The name of the imported function.



The type that the function returns. Do not use this attribute if the function does not return a value. Otherwise, the value must be an EDMSimpleType, an entity type, a complex type, or a collection of entity types or complex types that is within scope of the model.

In a conceptual model for an application that targets the .NET Framework version 3.5 SP1, the return type must be a collection of EDMSimpleTypes or entity types.



If the function returns a collection of entity types, the value of the EntitySet must be the entity set to which the collection belongs. Otherwise, the EntitySet attribute must not be used.

Any number of annotation attributes (custom XML attributes) may be applied to the FunctionImport element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.


The following example shows a FunctionImport element that accepts one parameter and returns a collection of entity types:

<FunctionImport Name="GetStudentGrades" 
       <Parameter Name="StudentID" Mode="In" Type="Int32" />

See Also