【发布时间】:2015-05-08 19:07:13
【问题描述】:
我有一个从 /$metadata 端点返回以下内容的 OData 服务:
<?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>
当我尝试对此 XML 文件运行 OData v4 Client Code Generator (v2.3.0) 时,我收到以下错误:
警告:正在运行转换:元素“edmx:Edmx”对于根元素来说是意外的。根元素应该是 Edmx。
警告:“http://schemas.microsoft.com/ado/2007/08/dataservices/metadata:DataServiceVersion”属性未声明。
我也只看到了一个空的.cs 输出文件。
我尝试从 <Edmx> 和 <DataServices> 元素中删除 edmx: 命名空间前缀,将该命名空间设为默认值,并调整其余元素的前缀,但这也不起作用:
<?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>
【问题讨论】: