OData v4 Client Code Generator

Microsoft Free

An item template that simplifies the process of accessing OData v4 services by generating C# and VB.Net client-side proxy classes.

(1) Review
Visual Studio
2015, 2013, 2012
Download (22,101)
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Reviews (1)
Q and A (23)
Sign in to write a review
Sort by:

by ImGonaRot | November 26 2014

Great start but falls short in a few areas such as authentication and function / action calls.

Sign in to start a discussion

  • Open Source
    3 Posts | Last post Tue 1:24 PM
    • Is this project open source?  I can't seem to find it in the OData repos on github https://github.com/OData.  Thanks.
    • Repo: odata.net - https://github.com/OData/odata.net/tree/master/src/CodeGen
    • Thank you Congyong
  • Visual Studio 2015 support
    1 Posts | Last post August 28, 2015
    • Any plan to support Visual Studio 2015?
  • Bug when returning string array
    2 Posts | Last post August 24, 2015
    • Let's assume you have a odata service that returns a string array.
      If you try to run the OData client template against the OData service that returns the string array then the generated client code will have a have a namespace of "System" and a class of "String[]".
      This will of course break all code since it is using the "System" namespace.
      'Generation date: 7/31/2014 4:56:19 PM
      Namespace System
          '''There are no comments for String[] in the schema.
      	<Global.Microsoft.OData.Client.OriginalNameAttribute("String[]")>  _
          Partial Public Class String[]
              Implements Global.System.ComponentModel.INotifyPropertyChanged
              ''' <summary>
              ''' This event is raised when the value of the property is changed
              ''' </summary>
              <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.0.0")>  _
              Public Event PropertyChanged As Global.System.ComponentModel.PropertyChangedEventHandler Implements Global.System.ComponentModel.INotifyPropertyChanged.PropertyChanged
              ''' <summary>
              ''' The value of the property is changed
              ''' </summary>
              ''' <param name="property">property name</param>
              <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.0.0")>  _
              Protected Overridable Sub OnPropertyChanged(ByVal [property] As String)
                  If (Not (Me.PropertyChangedEvent) Is Nothing) Then
                      RaiseEvent PropertyChanged(Me, New Global.System.ComponentModel.PropertyChangedEventArgs([property]))
                  End If
              End Sub
          End Class
          ''' <summary>
          ''' Class containing all extension methods
          ''' </summary>
          Public Module ExtensionMethods
          End Module
      End Namespace
    • Try using ReturnsCollection<string> rather than Returns<string[]>
       EntityTypeConfiguration<MyType> myTypeConfiguration = builder.EntityType<MyType>();
      ActionConfiguration myAction = myTypeConfiguration.Action("MyActionName").ReturnsCollection<string>();
      Hope that helps.
  • Any updates for VS2015?
    8 Posts | Last post August 15, 2015
    • Is there an ETA on when this will be available on VS2015?
    • Ditto!
    • +1
    • +1
    • +1
    • +1
    • It seems that an update is in the works  https://github.com/OData/odata.net/issues/234
    • meanwhile, you can download the vsix, rename extension to zip, unzip, open extension.vsixmanifest, add 
            <VisualStudio Version="14.0">
      under <SupportedProducts>, save, re-zip, change extension back to vsix and install.
  • Error with Nullable<int>
    2 Posts | Last post July 15, 2015
    • I just upgraded my OData Service and the Client Code Generator, and now some of my FOREIGN KEY fields are nullable.  
      Here are a few code snippets showing you want I mean:
      From SQL Schema (Merchants Table):
      [CoBrandId] INT NOT NULL,
      CONSTRAINT [FK_Merchants_CoBrands] FOREIGN KEY ([CoBrandId]) REFERENCES [CoBrands]([CoBrandId]),
      From Entity Class (Merchant):
      public int CoBrandId { get; set; }
      public virtual CoBrand CoBrand { get; set; }
      From OData generated Metadata:
      <EntityType Name="Merchant">
      		<PropertyRef Name="MerchantId"/>
      	<Property Name="MerchantId" Type="Edm.Int32" Nullable="false"/>
      	<Property Name="IsActive" Type="Edm.Boolean" Nullable="false"/>
      	<Property Name="CoBrandId" Type="Edm.Int32"/>
      	<NavigationProperty Name="CoBrand" Type="Entities.CoBrand">
      From Client Code Generator:
              /// <summary>
              /// There are no comments for Property CoBrandId in the schema.
              /// </summary>
              [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.1.0")]
              public global::System.Nullable<int> CoBrandId
                      return this._CoBrandId;
                      this._CoBrandId = value;
              [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.1.0")]
              private global::System.Nullable<int> _CoBrandId;
              partial void OnCoBrandIdChanging(global::System.Nullable<int> value);
    • I was experiencing the same issue. I'm using Entity Framework and have a Computer class which has a ClientID property and a matching Client virtual property (navigation property). The OData generated metadata didn't explicitly state that the ClientID wasn't nullable, so the code generator made it nullable.
      The fix that worked for me was to add the [Required] attribute to the Client navigation property on the Computer class.
  • Visual Studio Express Install
    3 Posts | Last post June 18, 2015
    • I downloaded and ran the VSix install by clicking on the download.
      I said that it installed but is not visible as an add template.
      Is there a way to install on the Visual Studio express 2013. and web 2013.
    • Same here I installed via nuget package manager. But still i can'r see the template.
      Please help.
    • Same here. Is this resolved yet?
  • Problem With String Collection Parameter
    1 Posts | Last post April 01, 2015
    • I have an OData Controller that has a function that has a parameter that is a string array. The OData Client T4 Template ver. 2.2.0 tries to create a partial class for String[], which will not compile:
          /// <summary>
          /// There are no comments for String[] in the schema.
          /// </summary>
          public partial class String[] : global::System.ComponentModel.INotifyPropertyChanged
      Is there something I can do to get the T4 Template to work, or is this a bug with the template?
  • It dosn't work with ASP.NET WebAPI OData.
    1 Posts | Last post March 13, 2015
    • I used this code generator with ASP.NET WebAPI OData. But it dosn't work.
      ASP.NET WebAPI generates edmx.
      <edmx:Edmx ...>
      OData v4 Client Code Generator can't parse this edmx. why??
  • Filtering a composable function result by the entity id property
    2 Posts | Last post February 16, 2015
    • I'm using a Web API OData service and have a client that uses the generator. Suppose we have an unbound and composable function which has the following metadata:
            <Function Name=""FunctionReturnsIQueryable"" IsComposable=""true"">
              <ReturnType Type=""Collection(WebTestsServer.Domain.ActionMethodsRoutingTests.PrimitiveEntity)"" />
      Here PrimitiveEntity is an entity. When I try to run the follwing query:
      (DataServiceQuery<PrimitiveEntity>)Client.FunctionReturnsIQueryable().Where(x => x.Id == 1).Execute();
      I can see in Fiddler the GET request for this url: http://localhost:59663/FunctionReturnsIQueryable()(1) 
      But it seems that the url should use the $filter query option instead, something like:
      http://localhost:59678/FunctionReturnsIQueryable()?$filter=Id eq 1 
      When I try to filter the query by any other entity property, not the identificator, I get the url like the last one and everything works fine.
    • @Ruslan Marchenko
      This is by design, when OData Client found that you are using the key property with 'eq' operator, it will translate it into a (key).But for other properties, it will translate it to $filter .
  • Expand is not working correctly
    1 Posts | Last post February 16, 2015
    • The expand is only showing the first object in the DataServiceCollection.
      For example: odata/Orders?$expand=OrderLines in a browser shows more than 1 order line.
      Also when using fiddler and the OData v4 Client Code Generator I can see that multiple order lines are being returned but once the OData v4 Client deserializes the json then it only adds the 1st item to the OrderLines property of Order.
1 - 10 of 23 Items