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

半城伤御伤魂 提交于 2019-12-11 11:15:59

问题


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.


回答1:


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

var eModel = new Microsoft.Data.Edm.Library.EdmModel();
...
eModel.SetEdmVersion(new Version(1, 0));


来源:https://stackoverflow.com/questions/22989362/generating-odata-metadata-with-the-schema-http-schemas-microsoft-com-ado-2007

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!