Export (0) Print
Expand All

Navigation Properties (EDM)

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

In the Entity Data Model (EDM), navigation properties are shortcut properties used to locate the entities at the ends of an association. For more information about associations, see Association (EDM).

Properties contain the information an entity is designed to provide. Navigation properties describe navigable paths between associations. For example, in an association between Customer and Order entities, the Customer entity can declare a NavigationProperty named Orders to represent the Order instances associated with that particular Customer instance. From an instance of either Customer or Order, the NavigationProperty makes it possible to locate the instance at the other end of the association.

In the EDM, the functionality of collections is implemented by using navigation properties and associations. The NavigationProperty named Orders on the Customer entity works like a collection. When the following schema is built, the object model will contain an Add method on the Orders property. New instances of the Order entity are added by using the method. The Orders NavigationProperty can be enumerated in loops just like .NET Framework collections.

The following schema excerpt shows how to create navigation properties on the Customer and Order entities:

<EntityType Name="Customer" >
      <PropertyRef Name=" CustomerId " />
    <Property Name="CustomerId" Type="Guid" Nullable="false" />
    <NavigationProperty Name="Orders" Relationship=Namespace.CustomerOrderType"
          FromRole="Customer" ToRole="Orders"/>

<EntityType Name="Order" Key="OrderId">
    <NavigationProperty Name="OrderedBy" Relationship="Namespace.Customer_Order"
          FromRole="Order" ToRole="Customer" />

<Association Name="Customer_Order">
    <End Role="Customer" Type="Namespace.Customers" Multiplicity="1" />
    <End Role="Orders" Type="Namespace.Order" Multiplicity="0..*" />
<!— Use a fully qualified name for the association in a Navigation Property.->

This example shows only the schema definition for navigation properties on Customer and Order. For information about mapping the association and navigation properties to storage, see Implementing Associations (EDM).

See Also

Community Additions

© 2015 Microsoft