3 Structure Examples

The following example shows a conceptual schema definition language (CSDL) that defines:

  • Customer, Order, and Product entity types.

  • Association (CustomerOrder) that associates Customer and Order entity types.

  • SalesOrder entity type that has Order as the BaseType.

  • Address complex type.

     <Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="Model1" Alias="Self">
       <EntityContainer Name="Model1Container" >
         <EntitySet Name="CustomerSet" EntityType="Model1.Customer" />
         <EntitySet Name="OrderSet" EntityType="Model1.Order" />
         <AssociationSet Name="CustomerOrder" Association="Model1.CustomerOrder">
           <End Role="Customer" EntitySet="CustomerSet" />
           <End Role="Order" EntitySet="OrderSet" />
         </AssociationSet>
       </EntityContainer>
       <EntityType Name="Customer">
         <Key>
           <PropertyRef Name="CustomerId" />
         </Key>
         <Property Name="CustomerId" Type="Int32" Nullable="false" />
         <Property Name="FirstName" Type="String" Nullable="true" />
         <Property Name="LastName" Type="String" Nullable="true" />
         <Property Name="AccountNumber" Type="Int32" Nullable="true" />
         <Property Name="Address" Type="Self.Address" Nullable="false" />
         <NavigationProperty Name="Orders" Relationship="Model1.CustomerOrder" FromRole="Customer" ToRole="Order" />
       </EntityType>
       <EntityType Name="Order">
         <Key>
           <PropertyRef Name="OrderId" />
         </Key>
         <Property Name="OrderId" Type="Int32" Nullable="false" />
         <Property Name="OrderDate" Type="Int32" Nullable="true" />
         <Property Name="Description" Type="String" Nullable="true" />
         <NavigationProperty Name="Customer" Relationship="Model1.CustomerOrder" FromRole="Order" ToRole="Customer" />
       </EntityType>
       <EntityType Name="SalesOrder" BaseType="Self.Order">
         <Property Name="Paid" Type="Boolean" Nullable="false" />
       </EntityType>
       <EntityType OpenType="true" Name="Product">
         <Key>
           <PropertyRef Name="ProductId" />
         </Key>
         <Property Name="ProductId" Type="Int32" Nullable="false" />
         <Property Name="Name" Type="String" Nullable="false" />
         <Property Name="Description" Type="String" Nullable="true" />
       </EntityType>
       <Association Name="CustomerOrder">
         <End Type="Model1.Customer" Role="Customer" Multiplicity="1" />
         <End Type="Model1.Order" Role="Order" Multiplicity="*" />
       </Association>
       <ComplexType Name="Address">
         <Property Name="Street" Type="String" Nullable="false" />
         <Property Name="City" Type="String" Nullable="false" />
         <Property Name="State" Type="String" Nullable="false" />
         <Property Name="Zip" Type="String" Nullable="false" />
         <Property Name="Position" Type="GeographyPoint" Nullable="false" SRID="4326" />
       </ComplexType>
     </Schema>
    
Show: