Condividi tramite


Schema Element (CSDL)

The Schema element is the root element of a conceptual schema in the Entity Data Model (EDM). The Schema element is the specification for the Namespace that contains entities and associations used by the object model being defined. The conceptual schema is defined in conceptual schema definition language (CSDL). The EntityType and Association elements in the conceptual schema are child elements of the Schema element.

The EntityContainer element is the specification for a class in the object model being designed. EntitySet and AssociationSet are child elements of EntityContainer.

For information about EntityType and Association elements, see the subtopics in this section. For information about the EntityContainer element, see EntityContainer Element (CSDL).

The following schema declaration shows the Schema element and its child elements.

<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 schema specifications are mapped to store schema definition language (SSDL) specifications in mapping specification language (MSL).

In This Section

The topics in this section describe the types and elements used to implement an object model built on the EDM. The Namespace attribute of the Schema element and the child elements of the Schema element, such as EntityType and Association, are described in the following topics:

Namespace Attribute (CSDL)

Using Element (CSDL)

Documentation Element (CSDL)

EntityType Element (CSDL)

ComplexType (CSDL)

Association Element (CSDL)

Extended Property (CSDL)

FunctionImport Element (CSDL)

Each of these types has child elements in the CSDL schema.

See Also

Concepts

EntityContainer Element (CSDL)
Implementing Entities (EDM)
Implementing Associations (EDM)

Other Resources

EDM Specifications