Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
PropertyRef Element (CSDL)

PropertyRef Element (CSDL)

The PropertyRef element in conceptual schema definition language (CSDL) references a property of an entity type to indicate that the property will perform one of the following roles:

  • Part of the entity's key (a property or a set of properties of an entity type that determine identity). One or more PropertyRef elements can be used to define an entity key. For more information, see Key element.

  • The dependent or principal end of a referential constraint. For more information, see ReferentialConstraint element.

The PropertyRef element can only have annotation elements (zero or more) as child elements.

Ee473439.note(en-us,VS.100).gifNote:
Annotation elements are only allowed in conceptual models for applications that target the .NET Framework version 4 or later. The XML namespace for such models is http://schemas.microsoft.com/ado/2008/09/edm.

Applicable Attributes

The table below describes the attributes that can be applied to the PropertyRef element.

Attribute Name Is Required Value

Name

Yes

The name of the referenced property.

Ee473439.note(en-us,VS.100).gifNote:
Any number of annotation attributes (custom XML attributes) may be applied to the PropertyRef element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.

Example

The example below defines an entity type (Book). The entity key is defined by referencing the ISBN property of the entity type.

<EntityType Name="Book">
  <Key>
    <PropertyRef Name="ISBN" />
  </Key>
  <Property Type="String" Name="ISBN" Nullable="false" />
  <Property Type="String" Name="Title" Nullable="false" />
  <Property Type="Decimal" Name="Revision" Nullable="false" Precision="29" Scale="29" />
  <NavigationProperty Name="Publisher" Relationship="BooksModel.PublishedBy"
                      FromRole="Book" ToRole="Publisher" />
  <NavigationProperty Name="Authors" Relationship="BooksModel.WrittenBy"
                      FromRole="Book" ToRole="Author" />
</EntityType>

In the next example, two PropertyRef elements are used to indicate that two properties (Id and PublisherId) are the principal and dependent ends of a referential constraint.

<Association Name="PublishedBy">
  <End Type="BooksModel.Book" Role="Book" Multiplicity="*" >
  </End>
  <End Type="BooksModel.Publisher" Role="Publisher" Multiplicity="1" />
  <ReferentialConstraint>
    <Principal Role="Publisher">
      <PropertyRef Name="Id" />
    </Principal>
    <Dependent Role="Book">
      <PropertyRef Name="PublisherId" />
    </Dependent>
  </ReferentialConstraint>
</Association>

See Also

Community Additions

ADD
Show:
© 2015 Microsoft