次の方法で共有


Dependent 要素 (SSDL)

ストア スキーマ定義言語 (SSDL) の Dependent 要素は ReferentialConstraint 要素の子であり、外部キー制約 (参照に関する制約とも呼ばれる) の依存 End を定義します。Dependent 要素は、1 つ以上の主キー列を参照する、テーブル内の 1 つ以上の列を指定します。PropertyRef 要素は、参照される列を指定します。Principal 要素は、Dependent 要素で指定されている列が参照する主キー列を指定します。

Dependent 要素には、次の子要素をここに示す順序で含めることができます。

適用可能な属性

次の表は、Dependent 要素に適用できる属性を示しています。

属性名

必須

Role

はい

対応する End 要素の Role 属性 (使用されている場合) と同じ値です。それ以外の場合は、参照している列を含んでいるテーブルの名前です。

注意

Dependent 要素には、任意の数の annotation 属性 (カスタム XML 属性) を適用できます。ただし、カスタム属性は CSDL 用に予約されたどの XML 名前空間にも属さない場合があります。カスタム属性の完全修飾名は一意である必要があります。

次の例は、ReferentialConstraint 要素を使用して FK_CustomerOrders 外部キー制約に参加する列を指定する Association 要素を示します。Dependent 要素は、制約の依存 End として Order テーブルの CustomerId 列を指定します。

<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>
<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>

<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>

関連項目

概念

エンティティ フレームワークの概要

SSDL 仕様

その他の技術情報

CSDL、SSDL、および MSL 仕様

ADO.NET Entity Data Model ツール