Wednesday, January 1, 2014

Relationships in Entity Framework

In Entity Framework, an entity can be related to other entities through an association (relationship). The relationship may be governed by a referential constraint, which describes which end in the relationship is a principal role and which is a dependent role. Navigation properties provide a way to navigate an association between two entity types.

Every object can have a navigation property for every relationship in which it participates. Navigation properties allow you to navigate and manage relationships in both directions, returning either a reference object (if the multiplicity is either one or zero-or-one) or a collection (if the multiplicity is many). You may also choose to have one-way navigation, in which case you define the navigation property on only one of the types that participates in the relationship and not on both.

when working with 1-to-1 or 1-to-0..1 relationships, there is no separate foreign key column, the primary key property acts as the foreign key and is always included in the model. When foreign key columns are not included in the model, the association information is managed as an independent object. Relationships are tracked through object references instead of foreign key properties. This type of association is called an independent association.

Difference between Navigation property and an association
Association acts as a foreign key while, navigation property allows you to navigate between entities.


0 comments:

Post a Comment

Powered by Blogger.


Software Architect at Surge Global/ Certified Scrum Master

Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.

Search This Blog

Facebook