Northwind Storage Schema (EDM)

Metadata describes the structure of a database used by an application built on the Entity Data Model (EDM). Metadata is defined in store schema definition language (SSDL). The following schema is the complete metadata specification for database tables that contain instances of the entities and associations defined in Northwind Conceptual Schema (EDM).

The schema starts with a specification of a target namespace: NorthwindLib.Target. This Namespace is used to identify the metadata in the mapping specification. Following the Namespace name, the <EntityContainer> tag specifies a name for the container the metadata describes. In this case, the database object is named dbo corresponding to the name of the partition identifier in the Northwind database.

Each of the entity types and entity sets previously defined in the conceptual schema definition language (CSDL) schema have EntityType and EntitySet specifications in the SSDL schema. The SSDL declarations describe the pre-existing tables that the CSDL adapted in its design specifications for entities and associations. In the SSDL schema, entity sets represent tables in the database. Instances of entity types are represented by rows in a table. The properties of entity types correspond to columns in the tables. The Key properties of SSDL types correspond to primary key columns of rows in database tables.

The following schema defines the storage metadata in the NorthwindLib.Target namespace.

<?xml version="1.0" encoding="utf-8"?>
<Schema xmlns:edm="https://schemas.microsoft.com/ado/2006/04/edm/ssdl" 
             xmlns="https://schemas.microsoft.com/ado/2006/04/edm/ssdl"
             Provider="System.Data.SqlClient"
             ProviderManifestToken="2005"
             Namespace="NorthwindLib.Target" Alias="Self" >

  <EntityType Name="Product">
    <Key>
      <PropertyRef Name="ProductID" />
    </Key>
    <Property Name="ProductID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="ProductName" Type="nvarchar" Nullable="false" MaxLength="40" />
    <Property Name="CategoryID" Type="int" Nullable="true" />
    <Property Name="UnitPrice" Type="decimal" Nullable="true" Precision="10" Scale="4" />
    <Property Name="Discontinued" Type="bit" Nullable="false" />
    <Property Name="UnitsInStock" Type="smallint" Nullable="true" />
  </EntityType>

  <EntityType Name="Category">
    <Key>
      <PropertyRef Name="CategoryID" />
    </Key>
    <Property Name="CategoryID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="CategoryName" Type="nvarchar" Nullable="false" MaxLength="15" />
    <Property Name="Description" Type="nvarchar" Nullable="true" MaxLength="255" />
  </EntityType>

  <EntityType Name="Customer">
    <Key>
      <PropertyRef Name="CustomerID" />
    </Key>
    <Property Name="CustomerID" Type="nchar" Nullable="false" MaxLength="5" />
    <Property Name="CompanyName" Type="nvarchar" Nullable="false" MaxLength="40" />
    <Property Name="ContactName" Type="nvarchar" Nullable="true" MaxLength="30" />
    <Property Name="City" Type="nvarchar" Nullable="true" MaxLength="15" />
    <Property Name="Country" Type="nvarchar" Nullable="true" MaxLength="15" />
  </EntityType>

  <EntityType Name="Order">
    <Key>
      <PropertyRef Name="OrderID" />
    </Key>
    <Property Name="OrderID" Type="int" Nullable="false" />
    <Property Name="CustomerID" Type="nchar" Nullable="true" MaxLength="5" />
    <Property Name="OrderDate" Type="datetime" Nullable="true" />
    <Property Name="ShipCity" Type="nvarchar" Nullable="true" MaxLength="15" />
    <Property Name="ShipCountry" Type="nvarchar" Nullable="true" MaxLength="15" />
  </EntityType>

  <EntityContainer Name="dbo">
    <EntitySet Name="Categories" EntityType="Self.Category" Schema="dbo" Table="Categories" />
    <EntitySet Name="Products" EntityType="Self.Product" Schema="dbo" Table="Products" />
    <EntitySet Name="Customers" EntityType="Self.Customer" Schema="dbo" Table="Customers" />
    <EntitySet Name="Orders" EntityType="Self.Order" Schema="dbo" Table="Orders" />
  </EntityContainer>

</Schema>

See Also

Concepts

Northwind Conceptual Schema (EDM)
Northwind Mapping Schema (EDM)
Building the Northwind Object Model (EDM)
Helper Methods (EDM)
Using the Northwind Object Model (EDM)

Other Resources

EDM Specifications
Schemas and Mapping Specification (Entity Framework)