End 要素 (CSDL)

概念スキーマ定義言語 (CSDL: Conceptual Schema Definition Language) の End 要素は、Association 要素または AssociationSet 要素の子にすることができます。 それぞれの場合において、End 要素の役割は異なっており、該当する属性も異なります。

Association 要素の子としての End 要素

End 要素 (Association 要素の子として) は、アソシエーションの一方の End にあるエンティティ型と、アソシエーションのその End に存在できるエンティティ型のインスタンス数を特定します。 Association ends are defined as part of an association; an association must have exactly two association ends. アソシエーションの 1 つの End にあるエンティティ型インスタンスには、ナビゲーション プロパティまたは外部キーからアクセスできます (エンティティ型で公開されている場合)。 詳細については、「NavigationProperty 要素」、「ReferentialConstraint 要素」、および「リレーションシップの定義と管理 (Entity Framework)」を参照してください。

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

適用可能な属性

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

属性名 必須 Value

Type

有効

アソシエーションの一方の End のエンティティ型の名前。

Role

いいえ

アソシエーション End の名前。 名前が指定されない場合、アソシエーション End のエンティティ型の名前が使用されます。

Multiplicity

有効

アソシエーション End に存在できるエンティティ型のインスタンス数に応じて、10..1、または * のいずれか。

  • 1 は、アソシエーション End に 1 個のエンティティ型インスタンスが存在することを示します。

  • 0..1 は、アソシエーション End に 0 個か 1 個のエンティティ型インスタンスが存在することを示します。

  • * は、アソシエーション End に 0 個、1 個、または複数個のエンティティ型インスタンスが存在することを示します。

Bb896235.note(ja-jp,VS.100).gif注 :
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 following example shows an Association element that defines the CustomerOrders association. The Multiplicity values for each End of the association indicate that many Orders can be associated with a Customer, but only one Customer can be associated with an Order. さらに、特定の Customer が削除されると、その Customer に関連付けられており ObjectContext に読み込まれている Orders もすべて削除されることが、OnDelete 要素によって示されています。

<Association Name="CustomerOrders">
  <End Type="ExampleModel.Customer" Role="Customer" Multiplicity="1" />
  <End Type="ExampleModel.Order" Role="Order" Multiplicity="*">
        <OnDelete Action="Cascade" />
  </End>
</Association>

AssociationSet 要素の子としての End 要素

End 要素は、アソシエーション セットの 1 つの End を指定します。 AssociationSet 要素には、2 個の End 要素が含まれている必要があります。 End 要素に格納されている情報は、アソシエーション セットをデータ ソースにマップするときに使用されます。 詳細については、「AssociationSetMapping 要素 (MSL)」および「EndProperty 要素 (MSL)」を参照してください。

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

Bb896235.note(ja-jp,VS.100).gif注 :
Annotation 要素は、それ以外のすべての子要素より後に指定する必要があります。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 https://schemas.microsoft.com/ado/2008/09/edm.

適用可能な属性

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

属性名 必須 Value

EntitySet

有効

AssociationSet 要素の 1 つの End を定義する EntitySet 要素の名前。 EntitySet 要素は、親 AssociationSet 要素と同じエンティティ コンテナー内で定義されている必要があります。

Role

いいえ

アソシエーション セット End の名前。 Role 属性が使用されない場合、アソシエーション セット End の名前がエンティティ セット名になります。

Bb896235.note(ja-jp,VS.100).gif注 :
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.カスタム属性の完全修飾名は一意である必要があります。

次の例では、2 個の AssociationSet 要素を持つ EntityContainer 要素を示します。各 AssociationSet 要素には End 要素が 2 個あります。

<EntityContainer Name="BooksContainer" >
  <EntitySet Name="Books" EntityType="BooksModel.Book" />
  <EntitySet Name="Publishers" EntityType="BooksModel.Publisher" />
  <EntitySet Name="Authors" EntityType="BooksModel.Author" />
  <AssociationSet Name="PublishedBy" Association="BooksModel.PublishedBy">
    <End Role="Book" EntitySet="Books" />
    <End Role="Publisher" EntitySet="Publishers" />
  </AssociationSet>
  <AssociationSet Name="WrittenBy" Association="BooksModel.WrittenBy">
    <End Role="Book" EntitySet="Books" />
    <End Role="Author" EntitySet="Authors" />
  </AssociationSet>
</EntityContainer>

参照

概念

エンティティ フレームワークの概要
CSDL 仕様
Schema 要素 (CSDL)
EntityContainer 要素 (CSDL)

その他のリソース

CSDL、SSDL、および MSL 仕様
ADO.NET Entity Data Model Tools
association end (Entity Data Model)
association set (Entity Data Model)
association set end (Entity Data Model)