Tham khảo tài liệu 'pro entity framework 4 0 depositfiles_4', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | CHAPTER 7 RELATIONSHIPS AND ASSOCIATIONS Contact s Properties ContactID 2Ế NameStyle ấ Title 2 FirstName 2 MiddleName 2S LastName 2 Suffix Employee Properties EmployeelD 2 NationallDNum. 2 ContactID 2 LoginlD 2Ề ManagerlD Title 25 BirthDate 2 MaritalStatus 2 Gender 2 Email Address 2 j EmailPromotion 2 5 Phone 2 PasswordHash 23 PasswordSalt 2 AdditionalConta. 23 rowguid 1 2 r Hire Date 25 SalariedFlag 2fj VacationHours 2 Sic kLeaveH ours 2 CurrentFlag 2 rowguid 2Ĩ ModifiedDate 23 Modified Date s Navigation Properties B Navigation Properties Employees Contact Employeel Employee ị 01 I Figure 7-6. Entities defined in EF Many of the changes that Microsoft made were to the EDM. You can see in Figure 7-7 that the properties page for the association has been modified. The information in the properties page isn t that different from EF but you can see some property naming differences as well as a few additions. You now have End1 and End2 differentiation and you still have the Multiplicity and Role for each end. New to EF on this page is the OnDelete property for each end which specifies the action to be taken when an entity on this specified end is deleted. Your options for the OnDelete property are None and Cascade. Figure 7-7. association properties 115 CHAPTER 7 RELATIONSHIPS AND ASSOCIAATIONS Microsoft also added a couple of new visual items to the UI to help define and manage relationships between entities. These items and features are discussed in the following sections. Defining Referential Constraints Back in the EDM Designer double-click the association between the two entities. In EF a new Referential Constraint dialog opens showing the foreign key properties for the relationship see Figure 7-8 . Figure 7-8. Referential Contstraint Dialog The Referential Constraint dialog allows you to define the foreign key FK constraint between the source entity and the target entity. How do you know which is the target and which is the source If it isn t