Schema Element (CSDL)

The Schema element is the root element of a conceptual model definition. It contains definitions for the objects, functions, and containers that make up a conceptual model.

The Schema element may contain zero or more of the following child elements:

A Schema element may contain zero or one Annotation elements.


The Function element and annotation elements are only allowed in conceptual models for applications that target the .NET Framework version 4 or later. The XML namespace for such models is

The Schema element uses the Namespace attribute to define the namespace for the entity type, complex type, and association objects in a conceptual model. Within a namespace, no two objects can have the same name. Namespaces can span multiple Schema elements and multiple .csdl files.

A conceptual model namespace is different from the XML namespace of the Schema element. A conceptual model namespace (as defined by the Namespace attribute) is a logical container for entity types, complex types, and association types. The XML namespace (indicated by the xmlns attribute) of a Schema element is the default namespace for child elements and attributes of the Schema element. XML namespaces of the form (where YYYY and MM represent a year and month respectively) are reserved for CSDL. Custom elements and attributes cannot be in namespaces that have this form.

Applicable Attributes

The table below describes the attributes can be applied to the Schema element.

Attribute Name Is Required Value



The namespace of the conceptual model. The value of the Namespace attribute is used to form the fully qualified name of a type. For example, if an EntityType named Customer is in the Simple.Example.Model namespace, then the fully qualified name of the EntityType is SimpleExampleModel.Customer.

The following strings cannot be used as the value for the Namespace attribute: System, Transient, or Edm. The value for the Namespace attribute cannot be the same as the value for the Namespace attribute in the SSDL Schema element.



An identifier used in place of the namespace name. For example, if an EntityType named Customer is in the Simple.Example.Model namespace and the value of the Alias attribute is Model, then you can use Model.Customer as the fully qualified name of the EntityType.


Any number of annotation attributes (custom XML attributes) may be applied to the Schema element. However, custom attributes may not belong to any XML namespace that is reserved for CSDL. The fully-qualified names for any two custom attributes cannot be the same.


The following example shows a Schema element that contains an EntityContainer element, two EntityType elements, and one Association element.

<Schema xmlns="" 
      Namespace="ExampleModel" Alias="Self">
        <EntityContainer Name="ExampleModelContainer">
          <EntitySet Name="Customers" 
                     EntityType="ExampleModel.Customer" />
          <EntitySet Name="Orders" EntityType="ExampleModel.Order" />
            <End Role="Customer" EntitySet="Customers" />
            <End Role="Order" EntitySet="Orders" />
        <EntityType Name="Customer">
            <PropertyRef Name="CustomerId" />
          <Property Type="Int32" Name="CustomerId" Nullable="false" />
          <Property Type="String" Name="Name" Nullable="false" />
                   FromRole="Customer" ToRole="Order" />
        <EntityType Name="Order">
            <PropertyRef Name="OrderId" />
          <Property Type="Int32" Name="OrderId" Nullable="false" />
          <Property Type="Int32" Name="ProductId" Nullable="false" />
          <Property Type="Int32" Name="Quantity" Nullable="false" />
                   FromRole="Order" ToRole="Customer" />
          <Property Type="Int32" Name="CustomerId" Nullable="false" />
        <Association Name="CustomerOrders">
          <End Type="ExampleModel.Customer" 
               Role="Customer" Multiplicity="1" />
          <End Type="ExampleModel.Order" 
               Role="Order" Multiplicity="*" />
            <Principal Role="Customer">
              <PropertyRef Name="CustomerId" />
            <Dependent Role="Order">
              <PropertyRef Name="CustomerId" />

See Also


Entity Framework Overview
CSDL Specification

Other Resources

CSDL, SSDL, and MSL Specifications
ADO.NET Entity Data Model Tools