Database Reference
In-Depth Information
How It Works
To map the stored procedures to the Insert and Delete actions for the many-to-many association, we created the
stored procedures in our database and then updated the model with the stored procedures.
Because Entity Framework's designer does not currently support mapping stored procedures to the Insert
and Delete actions for associations, we need to edit the .edmx file directly. In the Mappings section, we added a
<ModificationFunctionMapping> tag that maps the Insert and Delete actions for the association to our stored
procedures. In this tag, we refer to the InsertAuthorBook and DeleteAuthorBook stored procedures, which are
defined in the Store model because we updated the model with these stored procedures from the database.
In the trace from Listing 10-25, we can see not only the expected inserts for the Author and Book tables, but we
can also see that our stored procedures are used to insert and delete the association.
10-10. Mapping the Insert, Update, and Delete Actions to Stored
Procedures for Table per Hierarchy Inheritance
Problems
You have a model that uses Table per Hierarchy inheritance, and you want to map the Insert, Update, and Delete
actions to stored procedures.
Solution
Let's say that your database contains a Product table that describes a couple of different kinds of products (see
Figure 10-14 ). You have created a model with derived types for each of the product types represented in the Product
table. The model looks like the one shown in Figure 10-14 .
Figure 10-13. A Product table with a discriminator column, ProductType, that indicates the type of product described
by the row in the table
 
Search WWH ::




Custom Search