Search code examples
asp.net-mvcodata

OData Client Code Generator not generating


I have installed the OData Client Code Generator tt template from https://visualstudiogallery.msdn.microsoft.com/9b786c0e-79d1-4a50-89a5-125e57475937

and have tried point them to my ASP MVC OData endpoint and also tried Edmx, both not working. I manage to save the tt file but the generated ODataClient.cs file is empty.

Here's how my ASP MVC OData read (no login and authentication required)

<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>


Solution

  • I found that I'm trying to generate the Client against OData v3. After upgrading to v4, it works just fine.

    Add "/$metadata" at the end of the OData url to check the version of OData you are using.