Conceptual Schema (CSDL)
The conceptual schema is a design template for the object model that will be used by applications built on the Entity Data Model (EDM). The namespace name declared in the conceptual schema will be the namespace name that qualifies the entity and association classes in the generated object model.
EDM architecture provides the basic structure of entities and associations. Application designers derive entities and associations based on these types. The types defined in the conceptual schema are mapped to metadata describing the storage model.
The conceptual schema uses an XML dialect called conceptual schema definition language (CSDL). Storage metadata uses an XML dialect called store schema definition language (SSDL).
CSDL namespaces are different from XML namespaces. CSDL namespaces are used to fully qualify entity type names and association names. For example, when mapping schema language (MSL) refers to entity types, the fully qualified name must be provided. Further, when classes are generated, the classes are created in a CLR namespace of the same name. CSDL is in the XML namespace
http://schemas.microsoft.com/ado/2006/04/edm. The two types of namespaces are separate and distinct, and should not be confused.
Namespace and Mapping
The root element of the conceptual schema is the Schema element. It contains a Namespace attribute that specifies the CSDL namespace. The namespace is used in the mapping specification to connect the CSDL types to storage metadata.
The following declaration from the CSDL schema contains the namespace that is used in the mapping specification to map entities and associations in the sample application AdventureWorksHRModel to storage metadata.
<?xml version="1.0" encoding="utf-8"?> <Schema Namespace="AdventureWorksHRModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
There is a similar line in the SSDL file.
<?xml version="1.0" encoding="utf-8"?> <Schema Namespace="AdventureWorksHRTarget" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
Namespace names used in these declarations reflect their purposes in the data model being constructed. AdventureWorksHRModel is the conceptual model that is mapped in these examples to the target metadata namespace AdventureWorksHRTarget.
The entity container elements in the conceptual and storage schemas are independent of the Schema element even though they are child elements of the Schema elements in both cases.
In the mapping specification, the EntityContainerMapping element maps the two container objects without reference to their namespace names:
edm:StorageEntityContainer="HumanResources". Using an entity container name qualified by the schema namespace name will cause a mapping exception.
The following mapping specification language (MSL) heading shows the mapping between the HumanResources entity container in the conceptual schema, here referred to as CdmEntityContainer, and the storage metadata, referred to as StorageEntityContainer.
<?xml version="1.0" encoding="utf-8"?> <Mapping edm:Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"> <EntityContainerMapping CdmEntityContainer="HumanResources" StorageEntityContainer="HumanResources">
Other CSDL schema elements are similarly mapped to SSDL specifications in the mapping specification. The topics in this section describe the types and elements used to implement an object model built on the EDM.