Schema 要素 (CSDL)

Schema 要素は、概念モデル定義のルート要素です。 概念モデルを構成するオブジェクト、関数、およびコンテナーの定義を格納します。

Schema 要素には、0 個以上の次の子要素を含めることができます。

Schema 要素には、0 個以上の Annotation 要素を含めることができます。

Bb399276.note(ja-jp,VS.100).gif注 :
Function 要素と annotation 要素は、.NET Framework Version 4 以降を対象としたアプリケーションの概念モデルでのみ使用できます。The XML namespace for such models is https://schemas.microsoft.com/ado/2008/09/edm.

Schema 要素は、Namespace 属性を使用して概念モデルのエンティティ型、複合型、およびアソシエーション オブジェクトの名前空間を定義します。 1 つの名前空間内で 2 つのオブジェクトが同じ名前を持つことはできません。 名前空間は、複数の Schema 要素と複数の .csdl ファイルにまたがることができます。

概念モデル名前空間は、Schema 要素の XML 名前空間とは異なります。 概念モデル名前空間 (Namespace 属性で定義) は、エンティティ型、複合型、およびアソシエーション型の論理コンテナーです。 Schema 要素の XML 名前空間 (xmlns 属性で示される) は、Schema 要素の子要素と属性の既定の名前空間です。 フォーム https://schemas.microsoft.com/ado/YYYY/MM/edm (YYYY と MM は、それぞれ年と月を表します) の XML 名前空間は、CSDL 用に予約されています。 カスタム要素と属性は、このフォームがある名前空間に存在することはできません。

適用可能な属性

The table below describes the attributes can be applied to the Schema element.

属性名 必須 Value

Namespace

有効

概念モデルの名前空間。 Namespace 属性の値は、型の完全修飾名を形成するために使用されます。 たとえば、Customer という名前の EntityType が Simple.Example.Model 名前空間にある場合、この EntityType の完全修飾名は SimpleExampleModel.Customer です。

Namespace 属性の値として、文字列 SystemTransient、または Edm を使用することはできません。 The value for the Namespace attribute cannot be the same as the value for the Namespace attribute in the SSDL Schema element.

Alias

いいえ

名前空間の名前の代わりに使用される識別子。 たとえば、Customer という名前の EntityType が、Simple.Example.Model 名前空間にあり、Alias 属性の値が Model である場合、Model.Customer を EntityType の完全修飾名として使用することができます。

Bb399276.note(ja-jp,VS.100).gif注 :
Schema 要素には、任意の数の annotation 属性 (カスタム XML 属性) を適用できます。However, custom attributes may not belong to any XML namespace that is reserved for CSDL.カスタム属性の完全修飾名は一意である必要があります。

The following example shows a Schema element that contains an EntityContainer element, two EntityType elements, and one Association element.

<Schema xmlns="https://schemas.microsoft.com/ado/2008/09/edm" 
     xmlns:cg="https://schemas.microsoft.com/ado/2006/04/codegeneration"
     xmlns:store="https://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" 
      Namespace="ExampleModel" Alias="Self">
        <EntityContainer Name="ExampleModelContainer">
          <EntitySet Name="Customers" 
                     EntityType="ExampleModel.Customer" />
          <EntitySet Name="Orders" EntityType="ExampleModel.Order" />
          <AssociationSet 
                      Name="CustomerOrder" 
                      Association="ExampleModel.CustomerOrders">
            <End Role="Customer" EntitySet="Customers" />
            <End Role="Order" EntitySet="Orders" />
          </AssociationSet>
        </EntityContainer>
        <EntityType Name="Customer">
          <Key>
            <PropertyRef Name="CustomerId" />
          </Key>
          <Property Type="Int32" Name="CustomerId" Nullable="false" />
          <Property Type="String" Name="Name" Nullable="false" />
          <NavigationProperty 
                   Name="Orders" 
                   Relationship="ExampleModel.CustomerOrders" 
                   FromRole="Customer" ToRole="Order" />
        </EntityType>
        <EntityType Name="Order">
          <Key>
            <PropertyRef Name="OrderId" />
          </Key>
          <Property Type="Int32" Name="OrderId" Nullable="false" />
          <Property Type="Int32" Name="ProductId" Nullable="false" />
          <Property Type="Int32" Name="Quantity" Nullable="false" />
          <NavigationProperty 
                   Name="Customer" 
                   Relationship="ExampleModel.CustomerOrders" 
                   FromRole="Order" ToRole="Customer" />
          <Property Type="Int32" Name="CustomerId" Nullable="false" />
        </EntityType>
        <Association Name="CustomerOrders">
          <End Type="ExampleModel.Customer" 
               Role="Customer" Multiplicity="1" />
          <End Type="ExampleModel.Order" 
               Role="Order" Multiplicity="*" />
          <ReferentialConstraint>
            <Principal Role="Customer">
              <PropertyRef Name="CustomerId" />
            </Principal>
            <Dependent Role="Order">
              <PropertyRef Name="CustomerId" />
            </Dependent>
          </ReferentialConstraint>
        </Association>
      </Schema>

参照

概念

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

その他のリソース

CSDL、SSDL、および MSL 仕様
ADO.NET Entity Data Model Tools