Database Reference
In-Depth Information
When you import these tables into a model, you get a model that looks like the one shown in Figure 10-12 .
Figure 10-12. The model created by importing the tables in Figure 10-11
To use stored procedures for the Insert and Delete actions, do the following.
1.
In your database, create the stored procedures in Listing 10-23.
Listing 10-23. The stored Procedures for the Insert and Delete Actions
create procedure [chapter10].[InsertAuthorBook]
(@AuthorId int,@BookId int)
as
begin
insert into chapter10.AuthorBook(AuthorId,BookId) values (@AuthorId,@BookId)
end
go
create procedure [chapter10].[DeleteAuthorBook]
(@AuthorId int,@BookId int)
as
begin
delete chapter10.AuthorBook where AuthorId = @AuthorId and BookId = @BookId
end
2.
Right-click the design surface, and select Update Model from Database. Select the new
stored procedures from Listing 10-23 and click Finish. This will add the stored procedures
to the model.
3.
The current release of Entity Framework does not have designer support for mapping
stored procedures to the Insert and Delete actions for an association. To perform this
mapping manually, right-click the .edmx file and select Open With † XML Editor. Add the
code in Listing 10-24 in the Mappings section inside the <AssociationSetMapping> tag.
 
Search WWH ::




Custom Search