Share via


Schema 項目 (CSDL)

Schema 項目是 實體資料模型 (EDM) 中概念結構描述的根項目。 Schema 項目是 Namespace 的規格,其中包含定義之物件模型所使用的實體和關聯。 概念結構描述是定義在概念結構定義語言 (CSDL) 中。 概念結構描述中的 EntityTypeAssociation 項目是 Schema 項目的子項目。

EntityContainer 項目是所設計之物件模型中類別的規格。EntitySetAssociationSetEntityContainer 的子項目。

如需 EntityTypeAssociation 項目的資訊,請參閱本章節的副主題。 如需 EntityContainer 項目的詳細資訊,請參閱 EntityContainer 項目 (CSDL)

下列結構描述宣告顯示 Schema 項目和它的子項目。

<Schema Namespace="AdventureWorksHRModel" Alias="Self" 
             xmlns="https://schemas.microsoft.com/ado/2006/04/edm">

  <EntityType Name="Department" 
    <Key>
        <PropertyRef Name="DepartmentID" />
    </Key>
    <Property Name="DepartmentID" Type="Int16" Nullable="false" />
    <Property Name="Name" Type="String" Nullable="false" />
    <Property Name="GroupName" Type="String" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
  </EntityType>

  <EntityType Name="Employee"
    <Key>
        <PropertyRef Name=EmployeeID>
    </Key>
    <Property Name="EmployeeID" Type="Int32" Nullable="false" />
    <Property Name="NationalIDNumber" Type="String" Nullable="false" />
    <Property Name="ContactID" Type="Int32" Nullable="false" />
    <Property Name="LoginID" Type="String" Nullable="false"/>
    <Property Name="Title" Type="String" Nullable="false" />
    <Property Name="BirthDate" Type="DateTime" Nullable="false" />
    <Property Name="MaritalStatus" Type="String" Nullable="false"
/>
    <Property Name="Gender" Type="String" Nullable="false"/>
    <Property Name="HireDate" Type="DateTime" Nullable="false" />
    <Property Name="SalariedFlag" Type="Boolean" Nullable="false" />
    <Property Name="VacationHours" Type="Int16" Nullable="false" />
    <Property Name="SickLeaveHours" Type="Int16" Nullable="false" />
    <Property Name="CurrentFlag" Type="Boolean" Nullable="false" />
    <Property Name="rowguid" Type="Guid" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
  </EntityType>

  <Association Name="Employee_EmployeeManagerID">
        <End Role="Employee" Type="Self.Employee" Multiplicity="0..1" />
        <End Role="Employee" Type="Self.Employee" Multiplicity="0..*" />
  </Association>

  <EntityContainer Name="HumanResources">
    <EntitySet Name="Department" EntityType="Self.Department" />
    <EntitySet Name="Employee" EntityType="Self.Employee" />
    <AssociationSet Name="Employee_EmployeeManagerID"
                    Association="Self.Employee_EmployeeManagerID">
      <End Role="Employee" EntitySet="Employee" />
       <End Role="Employee63" EntitySet="Employee" />
    </AssociationSet>
  </EntityContainer>

</Schema>

CSDL 結構描述規格會對應到對應規格語言 (MSL) 中的存放結構定義語言 (SSDL) 規格。

本章節內容

本章節的主題描述用來實作 EDM 上建置之物件模型的型別和項目。 下列主題描述 Schema 項目的 Namespace 屬性和 Schema 項目的子項目,例如 EntityTypeAssociation

Namespace 屬性 (CSDL)

EntityType 項目 (CSDL)

Association 項目 (CSDL)

這些型別在 CSDL 結構描述中都有子項目。

另請參閱

概念

EntityContainer 項目 (CSDL)
實作實體 (EDM)
實作關聯 (EDM)

其他資源

EDM 規格