AdventureWorks Sales Model

This topic contains the conceptual model, storage model, and mapping information for the AdventureWorks Sales model. The AdventureWorks Sales model is used in example code in the Entity Framework documentation and is based on the following tables in the AdventureWorks database:

  • Address

  • Contact

  • Product

  • SalesOrderDetail

  • SalesOrderHeader

Bb387147.note(en-us,VS.100).gifNote:
The AdventureWorks example database can be downloaded here: SQL Server Database Product Examples.

The conceptual model, storage model, and mapping information are expressed in conceptual schema definition language (CSDL), store schema definition language (SSDL), and mapping specification language (MSL), respectively. The recommended way to create these models and mappings is by using the Entity Data Model Wizard or the edmgen.exe command line tool.

Model and Mapping Definitions

The following are the conceptual model, storage model, and mappings for the AdventureWorks Sales model.

Conceptual Model

<Schema Namespace="AdventureWorksModel" Alias="Self" 
        xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" 
        xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
  <EntityContainer Name="AdventureWorksEntities">
    <EntitySet Name="Addresses" EntityType="AdventureWorksModel.Address" />
    <EntitySet Name="Contacts" EntityType="AdventureWorksModel.Contact" />
    <EntitySet Name="Products" EntityType="AdventureWorksModel.Product" />
    <EntitySet Name="SalesOrderDetails" EntityType="AdventureWorksModel.SalesOrderDetail" />
    <EntitySet Name="SalesOrderHeaders" EntityType="AdventureWorksModel.SalesOrderHeader" />
    <AssociationSet Name="FK_SalesOrderHeader_Address_BillToAddressID" 
                    Association="AdventureWorksModel.FK_SalesOrderHeader_Address_BillToAddressID">
      <End Role="Address" EntitySet="Addresses" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeaders" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Address_ShipToAddressID" 
                    Association="AdventureWorksModel.FK_SalesOrderHeader_Address_ShipToAddressID">
      <End Role="Address" EntitySet="Addresses" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeaders" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Contact_ContactID" 
                    Association="AdventureWorksModel.FK_SalesOrderHeader_Contact_ContactID">
      <End Role="Contact" EntitySet="Contacts" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeaders" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID" 
                    Association="AdventureWorksModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID">
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeaders" />
      <End Role="SalesOrderDetail" EntitySet="SalesOrderDetails" />
    </AssociationSet>
  </EntityContainer>
  <EntityType Name="Address">
    <Key>
      <PropertyRef Name="AddressID" />
    </Key>
    <Property Name="AddressID" Type="Int32" Nullable="false" 
              annotation:StoreGeneratedPattern="Identity" />
    <Property Name="AddressLine1" Type="String" Nullable="false" MaxLength="60" 
              Unicode="true" FixedLength="false" />
    <Property Name="AddressLine2" Type="String" MaxLength="60" 
              Unicode="true" FixedLength="false" />
    <Property Name="City" Type="String" Nullable="false" MaxLength="30" 
              Unicode="true" FixedLength="false" />
    <Property Name="StateProvinceID" Type="Int32" Nullable="false" />
    <Property Name="PostalCode" Type="String" Nullable="false" MaxLength="15" 
              Unicode="true" FixedLength="false" />
    <Property Name="rowguid" Type="Guid" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
    <NavigationProperty Name="SalesOrderHeaders" 
                        Relationship="AdventureWorksModel.FK_SalesOrderHeader_Address_BillToAddressID" 
                        FromRole="Address" ToRole="SalesOrderHeader" />
    <NavigationProperty Name="SalesOrderHeaders1" 
                        Relationship="AdventureWorksModel.FK_SalesOrderHeader_Address_ShipToAddressID" 
                        FromRole="Address" ToRole="SalesOrderHeader" />
  </EntityType>
  <EntityType Name="Contact">
    <Key>
      <PropertyRef Name="ContactID" />
    </Key>
    <Property Name="ContactID" Type="Int32" Nullable="false" 
              annotation:StoreGeneratedPattern="Identity" />
    <Property Name="NameStyle" Type="Boolean" Nullable="false" />
    <Property Name="Title" Type="String" MaxLength="8" 
              Unicode="true" FixedLength="false" />
    <Property Name="FirstName" Type="String" Nullable="false" MaxLength="50" 
              Unicode="true" FixedLength="false" />
    <Property Name="MiddleName" Type="String" MaxLength="50" 
              Unicode="true" FixedLength="false" />
    <Property Name="LastName" Type="String" Nullable="false" MaxLength="50" 
              Unicode="true" FixedLength="false" />
    <Property Name="Suffix" Type="String" MaxLength="10" 
              Unicode="true" FixedLength="false" />
    <Property Name="EmailAddress" Type="String" MaxLength="50" 
              Unicode="true" FixedLength="false" />
    <Property Name="EmailPromotion" Type="Int32" Nullable="false" />
    <Property Name="Phone" Type="String" MaxLength="25" 
              Unicode="true" FixedLength="false" />
    <Property Name="PasswordHash" Type="String" Nullable="false" MaxLength="128" 
              Unicode="false" FixedLength="false" />
    <Property Name="PasswordSalt" Type="String" Nullable="false" MaxLength="10" 
              Unicode="false" FixedLength="false" />
    <Property Name="AdditionalContactInfo" Type="String" MaxLength="Max" 
              Unicode="true" FixedLength="false" />
    <Property Name="rowguid" Type="Guid" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
    <NavigationProperty Name="SalesOrderHeaders" 
                        Relationship="AdventureWorksModel.FK_SalesOrderHeader_Contact_ContactID" 
                        FromRole="Contact" ToRole="SalesOrderHeader" />
  </EntityType>
  <EntityType Name="Product">
    <Key>
      <PropertyRef Name="ProductID" />
    </Key>
    <Property Name="ProductID" Type="Int32" Nullable="false" 
              annotation:StoreGeneratedPattern="Identity" />
    <Property Name="Name" Type="String" Nullable="false" MaxLength="50" 
              Unicode="true" FixedLength="false" />
    <Property Name="ProductNumber" Type="String" Nullable="false" MaxLength="25" 
              Unicode="true" FixedLength="false" />
    <Property Name="MakeFlag" Type="Boolean" Nullable="false" />
    <Property Name="FinishedGoodsFlag" Type="Boolean" Nullable="false" />
    <Property Name="Color" Type="String" MaxLength="15" Unicode="true" FixedLength="false" />
    <Property Name="SafetyStockLevel" Type="Int16" Nullable="false" />
    <Property Name="ReorderPoint" Type="Int16" Nullable="false" />
    <Property Name="StandardCost" Type="Decimal" Nullable="false" Precision="19" Scale="4" />
    <Property Name="ListPrice" Type="Decimal" Nullable="false" Precision="19" Scale="4" />
    <Property Name="Size" Type="String" MaxLength="5" Unicode="true" FixedLength="false" />
    <Property Name="SizeUnitMeasureCode" Type="String" MaxLength="3" 
              Unicode="true" FixedLength="true" />
    <Property Name="WeightUnitMeasureCode" Type="String" MaxLength="3" 
              Unicode="true" FixedLength="true" />
    <Property Name="Weight" Type="Decimal" Precision="8" Scale="2" />
    <Property Name="DaysToManufacture" Type="Int32" Nullable="false" />
    <Property Name="ProductLine" Type="String" MaxLength="2" Unicode="true" FixedLength="true" />
    <Property Name="Class" Type="String" MaxLength="2" Unicode="true" FixedLength="true" />
    <Property Name="Style" Type="String" MaxLength="2" Unicode="true" FixedLength="true" />
    <Property Name="ProductSubcategoryID" Type="Int32" />
    <Property Name="ProductModelID" Type="Int32" />
    <Property Name="SellStartDate" Type="DateTime" Nullable="false" />
    <Property Name="SellEndDate" Type="DateTime" />
    <Property Name="DiscontinuedDate" Type="DateTime" />
    <Property Name="rowguid" Type="Guid" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
  </EntityType>
  <EntityType Name="SalesOrderDetail">
    <Key>
      <PropertyRef Name="SalesOrderID" />
      <PropertyRef Name="SalesOrderDetailID" />
    </Key>
    <Property Name="SalesOrderID" Type="Int32" Nullable="false" />
    <Property Name="SalesOrderDetailID" Type="Int32" Nullable="false" 
              annotation:StoreGeneratedPattern="Identity" />
    <Property Name="CarrierTrackingNumber" Type="String" MaxLength="25" 
              Unicode="true" FixedLength="false" />
    <Property Name="OrderQty" Type="Int16" Nullable="false" />
    <Property Name="ProductID" Type="Int32" Nullable="false" />
    <Property Name="SpecialOfferID" Type="Int32" Nullable="false" />
    <Property Name="UnitPrice" Type="Decimal" Nullable="false" Precision="19" Scale="4" />
    <Property Name="UnitPriceDiscount" Type="Decimal" Nullable="false" 
              Precision="19" Scale="4" />
    <Property Name="LineTotal" Type="Decimal" Nullable="false" Precision="38" Scale="6" 
              annotation:StoreGeneratedPattern="Computed" />
    <Property Name="rowguid" Type="Guid" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
    <NavigationProperty Name="SalesOrderHeader" 
                        Relationship="AdventureWorksModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID" 
                        FromRole="SalesOrderDetail" ToRole="SalesOrderHeader" />
  </EntityType>
  <EntityType Name="SalesOrderHeader">
    <Key>
      <PropertyRef Name="SalesOrderID" />
    </Key>
    <Property Name="SalesOrderID" Type="Int32" Nullable="false" 
              annotation:StoreGeneratedPattern="Identity" />
    <Property Name="RevisionNumber" Type="Byte" Nullable="false" />
    <Property Name="OrderDate" Type="DateTime" Nullable="false" />
    <Property Name="DueDate" Type="DateTime" Nullable="false" />
    <Property Name="ShipDate" Type="DateTime" />
    <Property Name="Status" Type="Byte" Nullable="false" />
    <Property Name="OnlineOrderFlag" Type="Boolean" Nullable="false" />
    <Property Name="SalesOrderNumber" Type="String" Nullable="false" MaxLength="25" 
              Unicode="true" FixedLength="false" 
              annotation:StoreGeneratedPattern="Computed" />
    <Property Name="PurchaseOrderNumber" Type="String" MaxLength="25" 
              Unicode="true" FixedLength="false" />
    <Property Name="AccountNumber" Type="String" MaxLength="15" 
              Unicode="true" FixedLength="false" />
    <Property Name="CustomerID" Type="Int32" Nullable="false" />
    <Property Name="ContactID" Type="Int32" Nullable="false" />
    <Property Name="SalesPersonID" Type="Int32" />
    <Property Name="TerritoryID" Type="Int32" />
    <Property Name="BillToAddressID" Type="Int32" Nullable="false" />
    <Property Name="ShipToAddressID" Type="Int32" Nullable="false" />
    <Property Name="ShipMethodID" Type="Int32" Nullable="false" />
    <Property Name="CreditCardID" Type="Int32" />
    <Property Name="CreditCardApprovalCode" Type="String" MaxLength="15" 
              Unicode="false" FixedLength="false" />
    <Property Name="CurrencyRateID" Type="Int32" />
    <Property Name="SubTotal" Type="Decimal" Nullable="false" Precision="19" Scale="4" />
    <Property Name="TaxAmt" Type="Decimal" Nullable="false" Precision="19" Scale="4" />
    <Property Name="Freight" Type="Decimal" Nullable="false" Precision="19" Scale="4" />
    <Property Name="TotalDue" Type="Decimal" Nullable="false" Precision="19" Scale="4" 
              annotation:StoreGeneratedPattern="Computed" />
    <Property Name="Comment" Type="String" MaxLength="128" Unicode="true" FixedLength="false" />
    <Property Name="rowguid" Type="Guid" Nullable="false" />
    <Property Name="ModifiedDate" Type="DateTime" Nullable="false" />
    <NavigationProperty Name="Address" 
                        Relationship="AdventureWorksModel.FK_SalesOrderHeader_Address_BillToAddressID" 
                        FromRole="SalesOrderHeader" ToRole="Address" />
    <NavigationProperty Name="Address1" 
                        Relationship="AdventureWorksModel.FK_SalesOrderHeader_Address_ShipToAddressID" 
                        FromRole="SalesOrderHeader" ToRole="Address" />
    <NavigationProperty Name="Contact" 
                        Relationship="AdventureWorksModel.FK_SalesOrderHeader_Contact_ContactID" 
                        FromRole="SalesOrderHeader" ToRole="Contact" />
    <NavigationProperty Name="SalesOrderDetails" 
                        Relationship="AdventureWorksModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID" 
                        FromRole="SalesOrderHeader" ToRole="SalesOrderDetail" />
  </EntityType>
  <Association Name="FK_SalesOrderHeader_Address_BillToAddressID">
    <End Role="Address" Type="AdventureWorksModel.Address" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.SalesOrderHeader" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Address">
        <PropertyRef Name="AddressID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="BillToAddressID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Address_ShipToAddressID">
    <End Role="Address" Type="AdventureWorksModel.Address" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.SalesOrderHeader" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Address">
        <PropertyRef Name="AddressID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="ShipToAddressID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Contact_ContactID">
    <End Role="Contact" Type="AdventureWorksModel.Contact" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.SalesOrderHeader" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Contact">
        <PropertyRef Name="ContactID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="ContactID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID">
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.SalesOrderHeader" Multiplicity="1">
      <OnDelete Action="Cascade" />
    </End>
    <End Role="SalesOrderDetail" Type="AdventureWorksModel.SalesOrderDetail" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="SalesOrderHeader">
        <PropertyRef Name="SalesOrderID" />
      </Principal>
      <Dependent Role="SalesOrderDetail">
        <PropertyRef Name="SalesOrderID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
</Schema>

Storage Model

<Schema Namespace="AdventureWorksModel.Store" Alias="Self" 
        Provider="System.Data.SqlClient" 
        ProviderManifestToken="2005" 
        xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" 
        xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
  <EntityContainer Name="AdventureWorksModelStoreContainer">
    <EntitySet Name="Address" EntityType="AdventureWorksModel.Store.Address" 
               store:Type="Tables" Schema="Person" />
    <EntitySet Name="Contact" EntityType="AdventureWorksModel.Store.Contact" 
               store:Type="Tables" Schema="Person" />
    <EntitySet Name="Product" EntityType="AdventureWorksModel.Store.Product" 
               store:Type="Tables" Schema="Production" />
    <EntitySet Name="SalesOrderDetail" EntityType="AdventureWorksModel.Store.SalesOrderDetail" 
               store:Type="Tables" Schema="Sales" />
    <EntitySet Name="SalesOrderHeader" EntityType="AdventureWorksModel.Store.SalesOrderHeader" 
               store:Type="Tables" Schema="Sales" />
    <AssociationSet Name="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID" 
                    Association="AdventureWorksModel.Store.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID">
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
      <End Role="SalesOrderDetail" EntitySet="SalesOrderDetail" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Address_BillToAddressID" 
                    Association="AdventureWorksModel.Store.FK_SalesOrderHeader_Address_BillToAddressID">
      <End Role="Address" EntitySet="Address" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Address_ShipToAddressID" 
                    Association="AdventureWorksModel.Store.FK_SalesOrderHeader_Address_ShipToAddressID">
      <End Role="Address" EntitySet="Address" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
    </AssociationSet>
    <AssociationSet Name="FK_SalesOrderHeader_Contact_ContactID" 
                    Association="AdventureWorksModel.Store.FK_SalesOrderHeader_Contact_ContactID">
      <End Role="Contact" EntitySet="Contact" />
      <End Role="SalesOrderHeader" EntitySet="SalesOrderHeader" />
    </AssociationSet>
  </EntityContainer>
  <EntityType Name="Address">
    <Key>
      <PropertyRef Name="AddressID" />
    </Key>
    <Property Name="AddressID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="AddressLine1" Type="nvarchar" Nullable="false" MaxLength="60" />
    <Property Name="AddressLine2" Type="nvarchar" MaxLength="60" />
    <Property Name="City" Type="nvarchar" Nullable="false" MaxLength="30" />
    <Property Name="StateProvinceID" Type="int" Nullable="false" />
    <Property Name="PostalCode" Type="nvarchar" Nullable="false" MaxLength="15" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="Contact">
    <Key>
      <PropertyRef Name="ContactID" />
    </Key>
    <Property Name="ContactID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="NameStyle" Type="bit" Nullable="false" />
    <Property Name="Title" Type="nvarchar" MaxLength="8" />
    <Property Name="FirstName" Type="nvarchar" Nullable="false" MaxLength="50" />
    <Property Name="MiddleName" Type="nvarchar" MaxLength="50" />
    <Property Name="LastName" Type="nvarchar" Nullable="false" MaxLength="50" />
    <Property Name="Suffix" Type="nvarchar" MaxLength="10" />
    <Property Name="EmailAddress" Type="nvarchar" MaxLength="50" />
    <Property Name="EmailPromotion" Type="int" Nullable="false" />
    <Property Name="Phone" Type="nvarchar" MaxLength="25" />
    <Property Name="PasswordHash" Type="varchar" Nullable="false" MaxLength="128" />
    <Property Name="PasswordSalt" Type="varchar" Nullable="false" MaxLength="10" />
    <Property Name="AdditionalContactInfo" Type="xml" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="Product">
    <Key>
      <PropertyRef Name="ProductID" />
    </Key>
    <Property Name="ProductID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
    <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
    <Property Name="ProductNumber" Type="nvarchar" Nullable="false" MaxLength="25" />
    <Property Name="MakeFlag" Type="bit" Nullable="false" />
    <Property Name="FinishedGoodsFlag" Type="bit" Nullable="false" />
    <Property Name="Color" Type="nvarchar" MaxLength="15" />
    <Property Name="SafetyStockLevel" Type="smallint" Nullable="false" />
    <Property Name="ReorderPoint" Type="smallint" Nullable="false" />
    <Property Name="StandardCost" Type="money" Nullable="false" />
    <Property Name="ListPrice" Type="money" Nullable="false" />
    <Property Name="Size" Type="nvarchar" MaxLength="5" />
    <Property Name="SizeUnitMeasureCode" Type="nchar" MaxLength="3" />
    <Property Name="WeightUnitMeasureCode" Type="nchar" MaxLength="3" />
    <Property Name="Weight" Type="decimal" Precision="8" Scale="2" />
    <Property Name="DaysToManufacture" Type="int" Nullable="false" />
    <Property Name="ProductLine" Type="nchar" MaxLength="2" />
    <Property Name="Class" Type="nchar" MaxLength="2" />
    <Property Name="Style" Type="nchar" MaxLength="2" />
    <Property Name="ProductSubcategoryID" Type="int" />
    <Property Name="ProductModelID" Type="int" />
    <Property Name="SellStartDate" Type="datetime" Nullable="false" />
    <Property Name="SellEndDate" Type="datetime" />
    <Property Name="DiscontinuedDate" Type="datetime" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="SalesOrderDetail">
    <Key>
      <PropertyRef Name="SalesOrderID" />
      <PropertyRef Name="SalesOrderDetailID" />
    </Key>
    <Property Name="SalesOrderID" Type="int" Nullable="false" />
    <Property Name="SalesOrderDetailID" Type="int" Nullable="false" 
              StoreGeneratedPattern="Identity" />
    <Property Name="CarrierTrackingNumber" Type="nvarchar" MaxLength="25" />
    <Property Name="OrderQty" Type="smallint" Nullable="false" />
    <Property Name="ProductID" Type="int" Nullable="false" />
    <Property Name="SpecialOfferID" Type="int" Nullable="false" />
    <Property Name="UnitPrice" Type="money" Nullable="false" />
    <Property Name="UnitPriceDiscount" Type="money" Nullable="false" />
    <Property Name="LineTotal" Type="numeric" Nullable="false" Precision="38" Scale="6" 
              StoreGeneratedPattern="Computed" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <EntityType Name="SalesOrderHeader">
    <Key>
      <PropertyRef Name="SalesOrderID" />
    </Key>
    <Property Name="SalesOrderID" Type="int" Nullable="false" 
              StoreGeneratedPattern="Identity" />
    <Property Name="RevisionNumber" Type="tinyint" Nullable="false" />
    <Property Name="OrderDate" Type="datetime" Nullable="false" />
    <Property Name="DueDate" Type="datetime" Nullable="false" />
    <Property Name="ShipDate" Type="datetime" />
    <Property Name="Status" Type="tinyint" Nullable="false" />
    <Property Name="OnlineOrderFlag" Type="bit" Nullable="false" />
    <Property Name="SalesOrderNumber" Type="nvarchar" Nullable="false" MaxLength="25" 
              StoreGeneratedPattern="Computed" />
    <Property Name="PurchaseOrderNumber" Type="nvarchar" MaxLength="25" />
    <Property Name="AccountNumber" Type="nvarchar" MaxLength="15" />
    <Property Name="CustomerID" Type="int" Nullable="false" />
    <Property Name="ContactID" Type="int" Nullable="false" />
    <Property Name="SalesPersonID" Type="int" />
    <Property Name="TerritoryID" Type="int" />
    <Property Name="BillToAddressID" Type="int" Nullable="false" />
    <Property Name="ShipToAddressID" Type="int" Nullable="false" />
    <Property Name="ShipMethodID" Type="int" Nullable="false" />
    <Property Name="CreditCardID" Type="int" />
    <Property Name="CreditCardApprovalCode" Type="varchar" MaxLength="15" />
    <Property Name="CurrencyRateID" Type="int" />
    <Property Name="SubTotal" Type="money" Nullable="false" />
    <Property Name="TaxAmt" Type="money" Nullable="false" />
    <Property Name="Freight" Type="money" Nullable="false" />
    <Property Name="TotalDue" Type="money" Nullable="false" 
              StoreGeneratedPattern="Computed" />
    <Property Name="Comment" Type="nvarchar" MaxLength="128" />
    <Property Name="rowguid" Type="uniqueidentifier" Nullable="false" />
    <Property Name="ModifiedDate" Type="datetime" Nullable="false" />
  </EntityType>
  <Association Name="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID">
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.Store.SalesOrderHeader" 
         Multiplicity="1">
      <OnDelete Action="Cascade" />
    </End>
    <End Role="SalesOrderDetail" Type="AdventureWorksModel.Store.SalesOrderDetail" 
         Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="SalesOrderHeader">
        <PropertyRef Name="SalesOrderID" />
      </Principal>
      <Dependent Role="SalesOrderDetail">
        <PropertyRef Name="SalesOrderID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Address_BillToAddressID">
    <End Role="Address" Type="AdventureWorksModel.Store.Address" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.Store.SalesOrderHeader" 
         Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Address">
        <PropertyRef Name="AddressID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="BillToAddressID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Address_ShipToAddressID">
    <End Role="Address" Type="AdventureWorksModel.Store.Address" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.Store.SalesOrderHeader" 
         Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Address">
        <PropertyRef Name="AddressID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="ShipToAddressID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <Association Name="FK_SalesOrderHeader_Contact_ContactID">
    <End Role="Contact" Type="AdventureWorksModel.Store.Contact" Multiplicity="1" />
    <End Role="SalesOrderHeader" Type="AdventureWorksModel.Store.SalesOrderHeader" 
         Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="Contact">
        <PropertyRef Name="ContactID" />
      </Principal>
      <Dependent Role="SalesOrderHeader">
        <PropertyRef Name="ContactID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
</Schema>

Mappings

<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
  <EntityContainerMapping StorageEntityContainer="AdventureWorksModelStoreContainer" 
                          CdmEntityContainer="AdventureWorksEntities">
    <EntitySetMapping Name="Addresses">
      <EntityTypeMapping TypeName="AdventureWorksModel.Address">
        <MappingFragment StoreEntitySet="Address">
          <ScalarProperty Name="AddressID" ColumnName="AddressID" />
          <ScalarProperty Name="AddressLine1" ColumnName="AddressLine1" />
          <ScalarProperty Name="AddressLine2" ColumnName="AddressLine2" />
          <ScalarProperty Name="City" ColumnName="City" />
          <ScalarProperty Name="StateProvinceID" ColumnName="StateProvinceID" />
          <ScalarProperty Name="PostalCode" ColumnName="PostalCode" />
          <ScalarProperty Name="rowguid" ColumnName="rowguid" />
          <ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
    <EntitySetMapping Name="Contacts">
      <EntityTypeMapping TypeName="AdventureWorksModel.Contact">
        <MappingFragment StoreEntitySet="Contact">
          <ScalarProperty Name="ContactID" ColumnName="ContactID" />
          <ScalarProperty Name="NameStyle" ColumnName="NameStyle" />
          <ScalarProperty Name="Title" ColumnName="Title" />
          <ScalarProperty Name="FirstName" ColumnName="FirstName" />
          <ScalarProperty Name="MiddleName" ColumnName="MiddleName" />
          <ScalarProperty Name="LastName" ColumnName="LastName" />
          <ScalarProperty Name="Suffix" ColumnName="Suffix" />
          <ScalarProperty Name="EmailAddress" ColumnName="EmailAddress" />
          <ScalarProperty Name="EmailPromotion" ColumnName="EmailPromotion" />
          <ScalarProperty Name="Phone" ColumnName="Phone" />
          <ScalarProperty Name="PasswordHash" ColumnName="PasswordHash" />
          <ScalarProperty Name="PasswordSalt" ColumnName="PasswordSalt" />
          <ScalarProperty Name="AdditionalContactInfo" ColumnName="AdditionalContactInfo" />
          <ScalarProperty Name="rowguid" ColumnName="rowguid" />
          <ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
    <EntitySetMapping Name="Products">
      <EntityTypeMapping TypeName="AdventureWorksModel.Product">
        <MappingFragment StoreEntitySet="Product">
          <ScalarProperty Name="ProductID" ColumnName="ProductID" />
          <ScalarProperty Name="Name" ColumnName="Name" />
          <ScalarProperty Name="ProductNumber" ColumnName="ProductNumber" />
          <ScalarProperty Name="MakeFlag" ColumnName="MakeFlag" />
          <ScalarProperty Name="FinishedGoodsFlag" ColumnName="FinishedGoodsFlag" />
          <ScalarProperty Name="Color" ColumnName="Color" />
          <ScalarProperty Name="SafetyStockLevel" ColumnName="SafetyStockLevel" />
          <ScalarProperty Name="ReorderPoint" ColumnName="ReorderPoint" />
          <ScalarProperty Name="StandardCost" ColumnName="StandardCost" />
          <ScalarProperty Name="ListPrice" ColumnName="ListPrice" />
          <ScalarProperty Name="Size" ColumnName="Size" />
          <ScalarProperty Name="SizeUnitMeasureCode" ColumnName="SizeUnitMeasureCode" />
          <ScalarProperty Name="WeightUnitMeasureCode" ColumnName="WeightUnitMeasureCode" />
          <ScalarProperty Name="Weight" ColumnName="Weight" />
          <ScalarProperty Name="DaysToManufacture" ColumnName="DaysToManufacture" />
          <ScalarProperty Name="ProductLine" ColumnName="ProductLine" />
          <ScalarProperty Name="Class" ColumnName="Class" />
          <ScalarProperty Name="Style" ColumnName="Style" />
          <ScalarProperty Name="ProductSubcategoryID" ColumnName="ProductSubcategoryID" />
          <ScalarProperty Name="ProductModelID" ColumnName="ProductModelID" />
          <ScalarProperty Name="SellStartDate" ColumnName="SellStartDate" />
          <ScalarProperty Name="SellEndDate" ColumnName="SellEndDate" />
          <ScalarProperty Name="DiscontinuedDate" ColumnName="DiscontinuedDate" />
          <ScalarProperty Name="rowguid" ColumnName="rowguid" />
          <ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
    <EntitySetMapping Name="SalesOrderDetails">
      <EntityTypeMapping TypeName="AdventureWorksModel.SalesOrderDetail">
        <MappingFragment StoreEntitySet="SalesOrderDetail">
          <ScalarProperty Name="SalesOrderID" ColumnName="SalesOrderID" />
          <ScalarProperty Name="SalesOrderDetailID" ColumnName="SalesOrderDetailID" />
          <ScalarProperty Name="CarrierTrackingNumber" ColumnName="CarrierTrackingNumber" />
          <ScalarProperty Name="OrderQty" ColumnName="OrderQty" />
          <ScalarProperty Name="ProductID" ColumnName="ProductID" />
          <ScalarProperty Name="SpecialOfferID" ColumnName="SpecialOfferID" />
          <ScalarProperty Name="UnitPrice" ColumnName="UnitPrice" />
          <ScalarProperty Name="UnitPriceDiscount" ColumnName="UnitPriceDiscount" />
          <ScalarProperty Name="LineTotal" ColumnName="LineTotal" />
          <ScalarProperty Name="rowguid" ColumnName="rowguid" />
          <ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
    <EntitySetMapping Name="SalesOrderHeaders">
      <EntityTypeMapping TypeName="AdventureWorksModel.SalesOrderHeader">
        <MappingFragment StoreEntitySet="SalesOrderHeader">
          <ScalarProperty Name="SalesOrderID" ColumnName="SalesOrderID" />
          <ScalarProperty Name="RevisionNumber" ColumnName="RevisionNumber" />
          <ScalarProperty Name="OrderDate" ColumnName="OrderDate" />
          <ScalarProperty Name="DueDate" ColumnName="DueDate" />
          <ScalarProperty Name="ShipDate" ColumnName="ShipDate" />
          <ScalarProperty Name="Status" ColumnName="Status" />
          <ScalarProperty Name="OnlineOrderFlag" ColumnName="OnlineOrderFlag" />
          <ScalarProperty Name="SalesOrderNumber" ColumnName="SalesOrderNumber" />
          <ScalarProperty Name="PurchaseOrderNumber" ColumnName="PurchaseOrderNumber" />
          <ScalarProperty Name="AccountNumber" ColumnName="AccountNumber" />
          <ScalarProperty Name="CustomerID" ColumnName="CustomerID" />
          <ScalarProperty Name="ContactID" ColumnName="ContactID" />
          <ScalarProperty Name="SalesPersonID" ColumnName="SalesPersonID" />
          <ScalarProperty Name="TerritoryID" ColumnName="TerritoryID" />
          <ScalarProperty Name="BillToAddressID" ColumnName="BillToAddressID" />
          <ScalarProperty Name="ShipToAddressID" ColumnName="ShipToAddressID" />
          <ScalarProperty Name="ShipMethodID" ColumnName="ShipMethodID" />
          <ScalarProperty Name="CreditCardID" ColumnName="CreditCardID" />
          <ScalarProperty Name="CreditCardApprovalCode" ColumnName="CreditCardApprovalCode" />
          <ScalarProperty Name="CurrencyRateID" ColumnName="CurrencyRateID" />
          <ScalarProperty Name="SubTotal" ColumnName="SubTotal" />
          <ScalarProperty Name="TaxAmt" ColumnName="TaxAmt" />
          <ScalarProperty Name="Freight" ColumnName="Freight" />
          <ScalarProperty Name="TotalDue" ColumnName="TotalDue" />
          <ScalarProperty Name="Comment" ColumnName="Comment" />
          <ScalarProperty Name="rowguid" ColumnName="rowguid" />
          <ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
        </MappingFragment>
      </EntityTypeMapping>
    </EntitySetMapping>
  </EntityContainerMapping>
</Mapping>

Connection String for the AdventureWorks Sales Model

The following is an example of a connection string for the AdventureWorks Sales model stored in the application configuration file. For more information, see Connection Strings.

<connectionStrings>
  <add name="AdventureWorksEntities" 
       connectionString="metadata=res://*/AdventureWorks.csdl
                        |res://*/AdventureWorks.ssdl
                        |res://*/AdventureWorks.msl;
                        provider=System.Data.SqlClient;
                        provider connection string=&quot;Data Source=localhost;
                                                        Initial Catalog=AdventureWorks;
                                                        Integrated Security=True;
                                                        MultipleActiveResultSets=True&quot;" 
       providerName="System.Data.EntityClient" />
</connectionStrings>

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft