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="">
  <edmx:DataServices xmlns:m="" m:DataServiceVersion="1.0">
    <Schema Namespace="(...)" xmlns:d="" xmlns:m="" xmlns="">
      <!-- ... -->


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 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="" xmlns:m="" xmlns:d="" xmlns:edm="">
  <DataServices m:DataServiceVersion="1.0">
    <edm:Schema Namespace="(...)">
      <!-- ... -->



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

. 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.



All Articles