共用方式為


Northwind 儲存結構描述 (EDM)

中繼資料會描述在 實體資料模型 (EDM) 上建置之應用程式所使用的資料庫結構。 中繼資料是定義在存放結構定義語言 (SSDL) 中。 下列結構描述是資料庫資料表的完整中繼資料規格,這些資料表包含 Northwind 概念結構描述 (EDM)中所定義之實體和關聯的執行個體。

此結構描述具有 target 命名空間的規格:NorthwindLib.Target。 這個 Namespace 是用來識別對應規格中的中繼資料。 <EntityContainer> 標記緊接在 Namespace 名稱的後面,它會針對中繼資料所描述的容器指定名稱。 在此情況下,資料庫物件會命名為 dbo,而且對應到 Northwind資料庫中資料分割識別碼的名稱。

之前在概念結構定義語言 (CSDL) 結構描述中定義的每一個實體類型和實體集在 SSDL 結構描述中都有 EntityTypeEntitySet 規格。 SSDL 宣告會描述 CSDL 為了適應其在實體和關聯上的設計規格而預先存在的資料表。 在 SSDL 結構描述中,實體集代表資料庫中的資料表。 實體類型的執行個體是由資料表中的資料列所表示。 實體類型的屬性會對應到資料表中的資料行。 SSDL 型別的 Key 屬性會對應到資料庫資料表中資料列的主索引鍵資料行。

下列結構描述會在 NorthwindLib.Target 命名空間中定義儲存中繼資料。

<?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>

另請參閱

概念

Northwind 概念結構描述 (EDM)
Northwind 對應結構描述 (EDM)
建置 Northwind 物件模型 (EDM)
Helper 方法 (EDM)
使用 Northwind 物件模型 (EDM)

其他資源

EDM 規格
結構描述和對應規格 (Entity Framework)