Share via


Namespace Attribute (SSDL)

In the Entity Data Model (EDM), the storage metadata Schema element contains a namespace name. The namespace name is used where a fully qualified name is required for declarations in the schema. The namespace name is often abbreviated by using an alias. The following example assigns the term Self to the Alias attribute of the AdventureWorksHRTarget schema.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="AdventureWorksHRTarget"
        Alias="Self"
        xmlns="https://schemas.microsoft.com/ado/2006/04/edm/ssdl">

There is a similar line in the conceptual schema definition language (CSDL) file. The only differences are in the names assigned to the Namespace attribute and the URL assigned to the xmlns attribute.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="AdventureWorksHRModel"
        Alias="Self"
        xmlns="https://schemas.microsoft.com/ado/2006/04/edm">

Namespace names used in these declarations reflect their purposes in the data model being constructed. AdventureWorksHRTarget is the target metadata used by the AdventureWorksHRModel to connect the types it defines to storage.

In the mapping specification, the EntityContainerMapping element maps the two entity containers without reference to their namespace names. The EntityContainer is separate and independent from the Schema even though it is defined in the Schema. The mapping specification refers only to container objects, as in the following mapping specification language (MSL) syntax: CdmEntityContainer="HumanResources" StorageEntityContainer="HumanResources".

<?xml version="1.0" encoding="utf-8"?>
<Mapping Space="C-S" 
    xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS">
  <EntityContainerMapping CdmEntityContainer="HumanResources"
                          StorageEntityContainer="HumanResources">

Alias

The Alias attribute is used to shorten the namespace name in the rest of the schema. The following example assigns the string Self to the Alias attribute.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="AdventureWorksHRModel"
        Alias="Self"
        xmlns="https://schemas.microsoft.com/ado/2006/04/edm">

The Alias is very useful in the rest of the schema and improves readability, as shown in the following syntax.

  <EntityContainer Name="HumanResources">
    <EntitySet Name="Department" EntityType="Self.Department" />
    <EntitySet Name="Employee" EntityType="Self.Employee" />
    <EntitySet Name="EmployeeAddress" EntityType="Self.EmployeeAddress" />

Xmlns

The previous example also contains an xmlns attribute that uses an assigned URL. This URL is used in all SSDL schemas.

See Also

Concepts

Conceptual Schema (CSDL)
Mapping Specification (MSL)
AdventureWorks Complete Model (EDM)