我已经创建了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 被指定为复杂类型在< em>系统命名空间。
我如何创建此服务参考?我正在使用VS 2015社区版。
谢谢!
答案 0 :(得分:0)
我发现只能为最高版本为3的OData服务创建服务引用。