Compartilhar via


PropertyRef Element (SSDL)

The PropertyRef element in store schema definition language (SSDL) references a property defined on an EntityType element to indicate that the property will perform one of the following roles:

  • Be part of the primary key of the table that the EntityType represents. One or more PropertyRef elements can be used to define a primary key. For more information, see Key element.

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

The PropertyRef element can only have the following child elements:

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.

Note

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 following example shows a PropertyRef element used to define a primary key by referencing a property that is defined on an EntityType element.

<EntityType Name="Customers">
  <Documentation>
    <Summary>Summary here.</Summary>
    <LongDescription>Long description here.</LongDescription>
  </Documentation>
  <Key>
    <PropertyRef Name="CustomerId" />
  </Key>
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <Property Name="Name" Type="nvarchar(max)" Nullable="false" />
</EntityType>

See Also

Concepts

Entity Framework Overview
SSDL Specification

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools