ModificationFunctionMapping (AssociationSetMapping)

As child element of an AssociationSetMapping element in the Entity Data Model (EDM), the ModificationFunctionMapping element specifies stored procedures that insert and delete instances of an Association between entities. Use a ModificationFunctionMapping element in an AssociationSetMapping element when you are mapping many-to-many associations that are supported by a link table in the storage model.

In an AssociationSetMappping function, the ModificationFunctionMapping element contains an InsertFunction element that identifies the stored procedure that creates the association between entities. The ModificationFunctionMapping element also includes a DeleteFunction element that identifies the stored procedure that deletes the association between entities. To define the entities in the association, both the InsertFunction and DeleteFunction elements use EndProperty child elements.

Note

The ModificationFunctionMapping element can also map stored procedures that insert, update, or delete instances of an EntityType element. In this instance, the ModificationFunctionMapping element is a child element of an EntityTypeMapping element that is, in turn, contained by the EntitySetMapping element. For more information, see ModificationFunctionMapping (EntityTypeMapping) and Stored Procedure Support (Entity Framework).

Example

In this example, the ModificationFunctionMapping element uses its InsertFunction and DeleteFunction elements to identify the stored procedures that create or delete associations between a Contact entity and an Address entity. To specify the Contact and Address entities, the InsertFunction and DeleteFunction elements use their EndProperty elements. These EndProperty elements use their ScalarProperty child elements to describe the parameter bindings for the key values of the entities at the ends of the Association. The ScalarProperty child elements also specify the corresponding parameters of stored procedures.

Note

The EndProperty bindings that are declared in an AssociationSet stored-procedure mapping resemble the AssociationEnd element that is declared in an EntitySet function mapping. However, for EndProperty elements, the AssociationSet element that contains them provides the necessary context.

The following example shows a complete AssociationSetMapping element with a ModificationFunctionMapping element:

  <AssociationSetMapping Name="Contact_Address"
                TypeName="ContactInformationModel.Contact_Address"
                StoreEntitySet="Contact_Address">
    <EndProperty Name="Address">
      <ScalarProperty Name="AddressID" ColumnName="AddressID" />
    </EndProperty>
    <EndProperty Name="Contact">
      <ScalarProperty Name="ContactID" ColumnName="ContactID" />
    </EndProperty>
    <ModificationFunctionMapping>
      <DeleteFunction
        FunctionName="ContactInformationModel.Store.DeleteAddress">
        <EndProperty Name="Address">
          <ScalarProperty Name="AddressID" ParameterName="AddressID"/>
        </EndProperty>
        <EndProperty Name="Contact">
          <ScalarProperty Name="ContactID" ParameterName="ContactID"/>
        </EndProperty>
      </DeleteFunction>
      <InsertFunction
        FunctionName="ContactInformationModel.Store.SetAddress">
        <EndProperty Name="Address">
          <ScalarProperty Name="AddressID" ParameterName="AddressID"/>
        </EndProperty>
        <EndProperty Name="Contact">
          <ScalarProperty Name="ContactID" ParameterName="ContactID"/>
        </EndProperty>
      </InsertFunction>
    </ModificationFunctionMapping>

See Also

Tasks

How to: Define a Model with a Stored Procedure (Entity Framework)

Concepts

Stored Procedure Support (Entity Framework)
InsertFunction (AssociationSetMapping
DeleteFunction (AssociationSetMapping)
EndProperty (AssociationSet ModificationFunctionMapping)