Generating OData $metadata with the schema http://schemas.microsoft.com/ado/2007/06/edmx

StackOverflow https://stackoverflow.com/questions/22989362

  •  01-07-2023
  •  | 
  •  

Question

When I use ODataLib 5.6.1 to generate an OData metadata document like this:

var eModel = new Microsoft.Data.Edm.Library.EdmModel();
.... 
...WriteMetadataDocument()
....

I get the following xml:

edmx document 1:

<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx" Version="3.0">
...
</edmx:Edmx> 

However this metadata (http://services.odata.org/V3/OData/OData.svc/$metadata) has a different schema:

edmx document 2:

<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
...
</edmx:Edmx> 

How can I generate metadata looking like the document 2? My motivation is that many OData clients (e.g. Visual Studio's "Add Service Reference") don't seem to recognize the document 1.

Était-ce utile?

La solution

After a while I figured out the trick (using SetEdmVersion):

var eModel = new Microsoft.Data.Edm.Library.EdmModel();
...
eModel.SetEdmVersion(new Version(1, 0));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top