OData 客户端代码生成器不生成

OData Client Code Generator not generating

我已经从 https://visualstudiogallery.msdn.microsoft.com/9b786c0e-79d1-4a50-89a5-125e57475937

安装了 OData 客户端代码生成器 tt 模板

并尝试将它们指向我的 ASP MVC OData 端点,还尝试了 Edmx,但均无法正常工作。我设法保存了 tt 文件,但生成的 ODataClient.cs 文件是空的.

这是我的 ASP MVC OData 读取方式(无需登录和身份验证)

<service xml:base="http://xxx.azurewebsites.net/odata">
  <workspace>
    <atom:title type="text">Default</atom:title>
    <collection href="Accesses">
      <atom:title type="text">Accesses</atom:title>
    </collection>
    <collection href="Badges">
      <atom:title type="text">Badges</atom:title>
    </collection>
    <collection href="BadgeTypes">
      <atom:title type="text">BadgeTypes</atom:title>
    </collection>
    <collection href="BookingItems">
      <atom:title type="text">BookingItems</atom:title>
    </collection>
    <collection href="Bookings">
      <atom:title type="text">Bookings</atom:title>
    </collection>
    <collection href="BookingStatuses">
      <atom:title type="text">BookingStatuses</atom:title>
    </collection>
    <collection href="Countries">
      <atom:title type="text">Countries</atom:title>
    </collection>
    <collection href="Holidays">
      <atom:title type="text">Holidays</atom:title>
    </collection>
    <collection href="Hotels">
      <atom:title type="text">Hotels</atom:title>
    </collection>
    <collection href="HotelStatuses">
      <atom:title type="text">HotelStatuses</atom:title>
    </collection>
    <collection href="RackRates">
      <atom:title type="text">RackRates</atom:title>
    </collection>
  </workspace>
</service>

我发现我正在尝试针对 OData v3 生成客户端。升级到v4后,一切正常

在 OData url 末尾添加 "/$metadata" 以检查您使用的 OData 版本。