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.

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

by rahul7720 | November 16 2015

Awesome tool.
Increased productivity.

No Annotations generated.

by LongDinhLe | October 21 2015

This scaffolding is pure awesomeness for OData v4..!

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

  • Data Annotations
    2 Posts | Last post November 16, 2015
    • Is there any plant for DataAnnotation support?
    • For Example:
      [Required ]
      [StringLength(20, Error="Please enter valid data")]
  • Send nested data
    1 Posts | Last post October 15, 2015
    • I have the following domain model:
      A company has 1 or more locations and every location has 1 address.
      So our database contains 3 tables.
      Company 1 .. * Location 1 .. 1 Address
      Our OData model is configured to have 3 entities, Company, Location and Address.
      When i use the Client Code Generator 3 classes are generated, so far so good.
      But when I want to submit data to the OData service I get three calls:
      - One call to [POST] /Company
      - One call to [POST] /Location
      - One call to [POST] /Address
      I would like to have just 1 call to /Company with all the data. 
      The company data, but also the nested location and address data.
      If I configure my OData service to use Complex types for Location and Address this is already happening.
      Is it possible to configure the code client generator in such a way that all data of an object is submitted?
  • Error with Nullable<int>
    3 Posts | Last post October 06, 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.
    • @Fazzamar Adding the required attribute did the trick for me. However, it is an interesting assumption to make a non nullable int field nullable with regards to the client code generator.  If we as developers wanted the foreign key field to be nullable we would explicitly set it to a nullable field.  I hope they fix this in the next iteration.  
  • Problem with nested objects
    2 Posts | Last post September 22, 2015
    • Hi,
      I'm using the entire extension over Web API 2.2.
      I'm trying to insert an object which contains nested objects, but the object is received by the API alone without the nested objects.
      Could you please tell me how to do this!
      Thanks in advance
    • We are also seeing this behavior where a child collection (navigation property) consisting of entities is not sent to the ASP.NET Web API OData service with its parent entity when attempting to POST the parent entity. For example, an order with its order line items. Since many of our entities contain related child entities (and they are set up in the EDM as entities), this behavior prevents us from using this otherwise seemingly useful template.
  • There are no comments for Property xx in the schema.
    1 Posts | Last post September 21, 2015
      I got this general comment for all properties:
      There are no comments for Property xx in the schema.
      Any clue to get the property descriptions?
  • Open Source
    3 Posts | Last post September 01, 2015
    • 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.
  • 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?
1 - 10 of 27 Items