Compartilhar via


End Element (SSDL)

The End element in store schema definition language (SSDL) specifies the table and number of rows at one end of a foreign key constraint in the underlying database. The End element can be a child of the Association element or the AssociationSet element. In each case, the possible child elements and applicable attributes are different.

End Element as a Child of the Association Element

An End element (as a child of the Association element) specifies the table and number of rows at the end of a foreign key constraint with the Type and Multiplicity attributes respectively. Ends of a foreign key constraint are defined as part of an SSDL association; an SSDL association must have exactly two ends.

An End element can have the following child elements (in the order listed):

Applicable Attributes

The following table describes the attributes that can be applied to the End element when it is the child of an Association element.

Attribute Name Is Required Value

Type

Yes

The fully qualified name of the SSDL entity set that is at the end of the foreign key constraint.

Role

No

The value of the Role attribute in either the Principal or Dependent element of the corresponding ReferentialConstraint element (if used).

Multiplicity

Yes

1, 0..1, or * depending on the number of rows that can be at the end of the foreign key constraint.

  • 1 indicates that exactly one row exists at the foreign key constraint end.

  • 0..1 indicates that zero or one row exists at the foreign key constraint end.

  • * indicates that zero, one, or more rows exist at the foreign key constraint end.

Note

Any number of annotation attributes (custom XML attributes) may be applied to the End 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 an Association element that defines the FK_CustomerOrders foreign key constraint. The Multiplicity values specified on each End element indicate that many rows in the Orders table can be associated with a row in the Customers table, but only one row in the Customers table can be associated with a row in the Orders table. Additionally, the OnDelete element indicates that all rows in the Orders table that reference a particular row in the Customers table will be deleted if the row in the Customers table is deleted.

<Association Name="FK_CustomerOrders">
  <End Role="Customers" 
       Type="ExampleModel.Store.Customers" Multiplicity="1">
    <OnDelete Action="Cascade" />
  </End>
  <End Role="Orders" 
       Type="ExampleModel.Store.Orders" Multiplicity="*" />
  <ReferentialConstraint>
    <Principal Role="Customers">
      <PropertyRef Name="CustomerId" />
    </Principal>
    <Dependent Role="Orders">
      <PropertyRef Name="CustomerId" />
    </Dependent>
  </ReferentialConstraint>
</Association>

End Element as a Child of the AssociationSet Element

The End element (as a child of the AssociationSet element) specifies a table at one end of a foreign key constraint in the underlying database.

An End element can have the following child elements (in the order listed):

Applicable Attributes

The following table describes the attributes that can be applied to the End element when it is the child of an AssociationSet element.

Attribute Name Is Required Value

EntitySet

Yes

The name of the SSDL entity set that is at the end of the foreign key constraint.

Role

No

The value of one of the Role attributes specified on one End element of the corresponding Association element.

Note

Any number of annotation attributes (custom XML attributes) may be applied to the End 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 an EntityContainer element with an AssociationSet element with two End elements:

<EntityContainer Name="ExampleModelStoreContainer">
  <EntitySet Name="Customers" 
             EntityType="ExampleModel.Store.Customers" 
             Schema="dbo" />
  <EntitySet Name="Orders" 
             EntityType="ExampleModel.Store.Orders" 
             Schema="dbo" />
  <AssociationSet Name="FK_CustomerOrders" 
                  Association="ExampleModel.Store.FK_CustomerOrders">
    <End Role="Customers" EntitySet="Customers" />
    <End Role="Orders" EntitySet="Orders" />
  </AssociationSet>
</EntityContainer>

See Also

Concepts

Entity Framework Overview
SSDL Specification

Other Resources

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