I would like to use the "Using" element in my *.csdl in order to import a other namespace, and use POCO to transform the objects.
I use a CSDL looks like this:
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm"
xmlns:cg="http://schemas.microsoft.com/ado/2006/04/codegeneration"
xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator"
Namespace="BooksModel" Alias="Self">
<Using Namespace="BooksModel.Extended" Alias="BMExt" />
<EntityContainer Name="BooksContainer" >
<EntitySet Name="Publishers" EntityType="BooksModel.Publisher" />
</EntityContainer>
<EntityType Name="Publisher">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" />
<Property Type="String" Name="Name" Nullable="false" />
<Property Type="BMExt.Address" Name="Address" Nullable="false" />
</EntityType>
</Schema>
(http://msdn.microsoft.com/en-us/library/bb738545.aspx)
However when I use a template (POCO) in order to transform my CSDL, the run tool throw an error of transformation:
Running transformation: No schema encountered with 'BooksModel.Extended' namespace. Make sure the namespace is correct or the schema defining the namespace is specified.
Running transformation: Unknown namespace or alias (BooksModel.Extended).
I load my CSDL like this:
var inputFile = @"CSDL_NAME.csdl";
var ItemCollection = loader.CreateEdmItemCollection(inputFile);
How can I modify the template in order to include the unknown namespace?
The problem behind the error is that you are not loading the other CSDL files in the EdmItemCollection. The solution is to load a String[] with the paths of the necessary CSDL files (including the ones with the imported namespaces) to the EdmItemCollection.
In code, it looks like this: