【发布时间】:2017-02-09 15:27:32
【问题描述】:
我创建了 Asp.Net Web API 2 OData 3 数据源。向http://localhost:3000/odata/$metadata 请求生成EDMX 方案:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="mPOS.API.Controllers">
<EntityType Name="Book">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" Type="Edm.String" Nullable="false"/>
<Property Name="Title" Type="Edm.String"/>
<Property Name="Count" Type="Edm.Int32"/>
<Property Name="Price" Type="System.Nullable_1OfMoney"/>
</EntityType>
</Schema>
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="System">
<ComplexType Name="Nullable_1OfMoney"/>
</Schema>
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="Default">
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="Books" EntityType="mPOS.API.Controllers.Book"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
当我尝试在客户端项目中创建服务引用时,出现错误:
0141:命名空间“System”是系统命名空间,不能被其他架构使用。选择另一个命名空间名称
所以生成的 EDMX 方案中的问题部分是属性 Price 类型 System.Nullable_1OfMoney 在定义的模式中指定为 Complex Type em>系统命名空间。
如何创建此服务参考?我正在使用 VS 2015 社区版。
谢谢!
【问题讨论】:
标签: c# visual-studio asp.net-web-api odata service-reference