我有一个WPF clinet,我正在使用 Odata客户端代码生成器,使用 Web Api 2 创建odata服务的客户端。
问题是我收到了一个空 .cs 文件,该文件是按照教程中描述的步骤创建的(上面给出了其链接)
我使用的 MatadataDocumentUri 是:http://localhost:56045/odata
我有什么遗失的吗?
以下是使用http://localhost:56045/odata/ $元数据的元数据:
<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="RestApiServer.Models">
<EntityType Name="User">
<Key>
<PropertyRef Name="UserId"/>
</Key>
<Property Name="UserId" Type="Edm.Int32" Nullable="false"/>
<Property Name="UserName" Type="Edm.String"/>
<Property Name="UserType" Type="Edm.String"/>
<NavigationProperty Name="UserAddress" Relationship="RestApiServer.Models.RestApiServer_Models_User_UserAddress_RestApiServer_Models_UserAddress_UserAddressPartner" ToRole="UserAddress" FromRole="UserAddressPartner"/>
</EntityType>
<EntityType Name="UserAddress">
<Property Name="UserId" Type="Edm.Int32" Nullable="false"/>
<Property Name="UserAddress1" Type="Edm.String"/>
<NavigationProperty Name="User" Relationship="RestApiServer.Models.RestApiServer_Models_UserAddress_User_RestApiServer_Models_User_UserPartner" ToRole="User" FromRole="UserPartner"/>
</EntityType>
<Association Name="RestApiServer_Models_User_UserAddress_RestApiServer_Models_UserAddress_UserAddressPartner">
<End Type="RestApiServer.Models.UserAddress" Role="UserAddress" Multiplicity="0..1"/>
<End Type="RestApiServer.Models.User" Role="UserAddressPartner" Multiplicity="0..1"/>
</Association>
<Association Name="RestApiServer_Models_UserAddress_User_RestApiServer_Models_User_UserPartner">
<End Type="RestApiServer.Models.User" Role="User" Multiplicity="0..1"/>
<End Type="RestApiServer.Models.UserAddress" Role="UserPartner" Multiplicity="0..1"/>
</Association>
</Schema>
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="Default">
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="Users" EntityType="RestApiServer.Models.User"/>
<EntitySet Name="UserAddresses" EntityType="RestApiServer.Models.UserAddress"/>
<AssociationSet Name="RestApiServer_Models_User_UserAddress_RestApiServer_Models_UserAddress_UserAddressPartnerSet" Association="RestApiServer.Models.RestApiServer_Models_User_UserAddress_RestApiServer_Models_UserAddress_UserAddressPartner">
<End Role="UserAddressPartner" EntitySet="Users"/>
<End Role="UserAddress" EntitySet="UserAddresses"/>
</AssociationSet>
<AssociationSet Name="RestApiServer_Models_UserAddress_User_RestApiServer_Models_User_UserPartnerSet" Association="RestApiServer.Models.RestApiServer_Models_UserAddress_User_RestApiServer_Models_User_UserPartner">
<End Role="UserPartner" EntitySet="UserAddresses"/>
<End Role="User" EntitySet="Users"/>
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
答案 0 :(得分:2)
您的元数据实际上是V3格式的元数据。请检查: http://services.odata.org/V4/OData/OData.svc/ $元数据,根目录是:
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
和http://services.odata.org/V3/OData/OData.svc/ $元数据
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
因此,您的服务实际上是OData V3服务,我们的客户端生成器尚不支持。