Now you’ll modify the model so that the Entity Framework will use the UpdateOrder stored procedure defined in the database instead of generating its own command. You’ll do this by mapping the UpdateOrder stored procedure to the Order entity in the designer. This is referred to as Stored Procedure Mapping or Function Mapping.
1.In the designer, right click on the Order entity and select Stored Procedure mapping.
2.Click select Function="" Insert="" and then click the drop down arrow that appears. This exposes the list of all Functions found in the Store metadata.
3.Select InsertOrder from the list. The designer will do its best job of matching the stored procedure’s parameters with the entity properties using the names. In this case, since all of the property names match the parameter names, it maps every one correctly so you don’t need to make any changes. One thing that the designer was not able to map is the newly generated SalesOrderID returned by the stored procedure. This is because the designer is not able to automatically detect the name of the field being returned.
4.Under the Result Column Bindings section, click add Binding="" Result="" and enter SalesOrderID. The designer should automatically select the entity key property, OrderID, for this final mapping.
When completed, Figure 6 displays what the mapping should look like.
From novice to tech pro — start learning today.