Conversion error when launching OData v4 Client Code Generator

I have an OData service that returns the /$metadata

following from an endpoint :

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
  <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
    <Schema Namespace="(...)" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
      <!-- ... -->
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>

      

When I try to run OData v4 Client Code Generator (v2.3.0) against this XML file, I get the following errors:

Warning: Transformation start: element "edmx: Edmx" was unexpected for root element. The root element must be Edmx.

Warning: The http://schemas.microsoft.com/ado/2007/08/dataservices/metadata:DataServiceVersion attribute has not been declared.

I also only see an empty file .cs

.

I tried removing the space prefix edmx:

from the elements <Edmx>

and <DataServices>

making that namespace the default and setting prefixes on the remaining elements, but that doesn't work either:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Edmx Version="1.0" xmlns="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:edm="http://schemas.microsoft.com/ado/2008/09/edm">
  <DataServices m:DataServiceVersion="1.0">
    <edm:Schema Namespace="(...)">
      <!-- ... -->
    </edm:Schema>
  </DataServices>
</Edmx>

      

+3


source to share


1 answer


Ok, it looks like the problem might be the version of OData that the service provides, namely OData v1.0 . The designated space edm

is this http://schemas.microsoft.com/ado/2006/04/edm

. See OData Version 4.0 Part 3: Common Schema Definition Language (CSDL), §2.2 :

The elements and attributes that define the entity model exposed by the OData service are qualified using the Entity model namespace:

Previous versions of CSDL for EDM used the following namespaces:



Using the Add Service Link tool in Visual Studio 2013 (optional with this update ) resolves the client code generation issue for this OData service.

+1


source







All Articles