Megosztás a következőn keresztül:


OnDelete Element (SSDL)

The OnDelete element in store schema definition language (SSDL) reflects the database behavior when a row that participates in a foreign key constraint is deleted. If the action is set to Cascade, then rows that reference a row that is being deleted will also be deleted. If the action is set to None, then rows that reference a row that is being deleted are not also deleted. An OnDelete element is a child element of an End element.

An OnDelete 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 OnDelete element.

Attribute Name Is Required Value

Action

Yes

Cascade or None. (The value Restricted is valid but has the same behavior as None.)

Note

Any number of annotation attributes (custom XML attributes) may be applied to the OnDelete element. However, custom attributes may not belong to any XML namespace that is reserved for SSDL. 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 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>

See Also

Concepts

Entity Framework Overview
SSDL Specification

Other Resources

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