Поделиться через


Schema Element (SSDL)

In the Entity Data Model (EDM), the Schema element is the root element in a storage metadata specification. The Schema element contains declarations and definitions of entities and associations that use the names and data types of the storage model. Storage metadata is defined in store schema definition language (SSDL).

The EntityType and Association elements are child elements of the Schema element. The EntitySet and AssociationSet elements are child elements of the EntityContainer element.

The EntityContainer element is contained by the Schema element, but it is separate and independent logically. In the mapping specification, the EntityContainer from the conceptual schema is mapped to the EntityContainer in the storage metadata without reference to the schema namespace.

The following SSDL schema excerpt shows the Schema element and the most important child elements that it contains.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="AdventureWorksHRTarget" Alias="Self"
          xmlns="https://schemas.microsoft.com/ado/2006/04/edm/ssdl">

  <EntityType Name="Department">
    <Key>
        <PropertyRef Name="DepartmentID">
    </Key>
    <Property Name="DepartmentID" Type="smallint"
                Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="Name" Type="nvarchar" 
                              Nullable="false" MaxLength="50" />
    <Property Name="GroupName" Type="nvarchar"
                              Nullable="false" MaxLength="50" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>

<EntityType Name="Employee" >
    <Key>
        <PropertyRef Name="EmployeeID">
    </Key>
    <Property Name="EmployeeID" Type="int" Nullable="false"
                                  StoreGeneratedPattern="Identity" />
    <Property Name="NationalIDNumber" Type="nvarchar"
                              Nullable="false" MaxLength="15" />
    <Property Name="ContactID" Type="int" Nullable="false" />
    <Property Name="LoginID" Type="nvarchar" 
                             Nullable="false" MaxLength="256" />
    <Property Name="ManagerID" Type="int" />
    <Property Name="Title" Type="nvarchar" Nullable="false"
                                                   MaxLength="50" />
    <Property Name="BirthDate" Type="datetime" Nullable="false" />
    <Property Name="MaritalStatus" Type="nchar" Nullable="false"
                                  MaxLength="1" FixedLength="true" />
    <Property Name="Gender" Type="nchar" Nullable="false"
                              MaxLength="1" FixedLength="true" />
    <Property Name="HireDate" Type="datetime" Nullable="false" />
    <Property Name="SalariedFlag" Type="bit" Nullable="false" />
    <Property Name="VacationHours" Type="smallint" Nullable="false" />
    <Property Name="SickLeaveHours" Type="smallint" Nullable="false" />
    <Property Name="CurrentFlag" Type="bit" Nullable="false" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>

<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="Employee" EntitySet="Employee" />
    </AssociationSet>
  </EntityContainer>

</Schema>

The Namespace attribute of the Schema type and the child elements of the Schema element such as EntityType and Association are described with their functions in the following topics:

Namespace Attribute (SSDL)

Documentation Element (SSDL)

ProviderManifestToken Attribute (SSDL)

EntityType Element (SSDL)

Association Element (SSDL)

Store Generated Pattern (SSDL)

Function Element (SSDL)

ComplexType (SSDL)

Each of these types have child elements in the SSDL schema.

See Also

Concepts

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

Other Resources

EDM Specifications