odata2poco - OData2Poco 6.0.0-dev-71

"OData2Poco is a class library supporting netstandard2,net6 and .NET 4.61+ to generate plain-old CLR objects (POCO/DTO) from OData feeds that implement both V1-3 and V4 OData protocol,based on the metadata of the service stored on the server. Code generation is controlled with lot of configuration parameters. POCO/DTO can be used in typed RESTful client OData services"

PM> Install-Package OData2Poco -Version 6.0.0-dev-71 -Source https://www.myget.org/F/odata2poco/api/v3/index.json

Copy to clipboard

> nuget.exe install OData2Poco -Version 6.0.0-dev-71 -Source https://www.myget.org/F/odata2poco/api/v3/index.json

Copy to clipboard

> dotnet add package OData2Poco --version 6.0.0-dev-71 --source https://www.myget.org/F/odata2poco/api/v3/index.json

Copy to clipboard
<PackageReference Include="OData2Poco" Version="6.0.0-dev-71" />
Copy to clipboard
source https://www.myget.org/F/odata2poco/api/v3/index.json

nuget OData2Poco  ~> 6.0.0-dev-71
Copy to clipboard

> choco install OData2Poco --version 6.0.0-dev-71 --source https://www.myget.org/F/odata2poco/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "odata2poco" -SourceLocation "https://www.myget.org/F/odata2poco/api/v2"
Install-Module -Name "OData2Poco" -RequiredVersion "6.0.0-dev-71" -Repository "odata2poco" -AllowPreRelease
Copy to clipboard

Browse the sources in this package using Visual Studio or WinDbg by configuring the following symbol server URL: https://www.myget.org/F/odata2poco/api/v2/symbolpackage/

Welcome to OData2Poco

OData2Poco is a code generation tool for generating plain-old CLR objects (POCO/DTO) in c# and typescript from OData feeds. POCO classes can be used in a typed RESTful client OData services. Code generation can be controlled by setting many options.

NuGet Version

NuGet Version

Global Tool NuGet Version


Continuous integration

Build server Platform Build status
AppVeyor Windows Build status
Travis Linux / OS X Build Status

Announcing new Release: V5.0.0

  • New feature: generating typescript code as a single file or multi files(modules).
  • New feature: Generating class with init-only property, the new feature in c# 9.
  • New feature: Generating record type, the new feature in c# 9.
  • Fix issue #29 and consider class dependency when filtering model.
  • Moving o2pgen cli console tool from net45 to net472, #44
  • Calculate checksum256 for all packages and saved to file hosted in github releases.
  • Auto puplishing the chocolatey package.

How to use the new features: read wiki

Development packages

The developed packages can be downloaded from myget.org

Give a Star! :star:

If you are using this project, please show your support by giving this project a star!. Thanks!

Features of OData2Poco

  • Generate POCO classes corresponding to the Entities defined in the XML MetaData stored in OData Feeds.
  • Generate c# code classes, classes with init-only properties of c#8 and records.
  • Generate typescript code as a single file or multi files(modules).
  • Generation is based on the Metadata of the service stored on the server/ EDMX xml files or xml string contents.
  • Support http(s) with/without authentication. The Supported autherizations are: basic, token and Oauth2.
  • Console CommandLine tool Support .NET472 or higher.
  • Class library Support NET6/netstandard2.0/net461.
  • Support Windows or Linux /OS fx (with mono installed) and NET6 (netcore).
  • Packaged as a nuget package in three different packages:
  • A Class library full framework/ netstandard2.0 /NET5 for programming.
  • A console CommandLine tool (one executable file o2pgen.exe)
  • Global net core support NET6 (dotnet-o2pgen).
  • Console tool o2pgen is published as a Chocolatey package.
  • Generating CSharp POCO classes. Other languages may be added in the near future based on the community needs.
  • Convert Data type of EDMX to the corresponding CLR data types.
  • Support Entites, complex data type, Collections and navigation properties.
  • Support OData service version V1..V4
  • Code generation is controlled by setting different options:
    • Add the following attributes: - Add Key Attributes. - Add Required Attributes to the properties. - Add JsonProperty Attribute to the properties. - Add Table Attribute to the class. - Add DataMember Attribute to the properties and DataContract Attribute to the class. - Add display attribute to the properties. - Add ProtoMember to the properties and ProtoContract to the class to suport Proto Buffer. - Add user defined attribute for the properties.

    • Adding virtual modifier to the properties.

    • Convert name of properties to camelCase or PasCase

    • Add nullable datatypes, e.g. int?.

    • Generate (or not) navigation properties.

    • Generated class follows inheritance hierarchy of OData feed (unless switched-off).

    • Generated class can inherit from a common BaseClass/interface.

    • Define namespace to overwrite the namespace of the model.

    • Filter Entities.

    • Name Mapping of Entities and properties using json file with regex support.

  • Add primary key/mandatory comments to the properties of the class.
  • Rename class/properties that have a name match a c# reserved keyword.
  • Save metadata and generated code to a user defined file name.
  • Support colored console windows /linux /OS fx.
  • Support Microsoft.OData.Edm library version 7.5+ (OData v4).
  • Support Microsoft.Data.Edm library (OData v1-v3).

Features added in V3.2.0:

  • New: Support Windows NTLM authentication(Thanks to @lobster2012-user for help).
  • New: Support Microsoft Digest authentication.
  • New: Support Integrated Windows Authentication, enabling users to log in with their Windows credentials (Issue#19).
  • New: Add jsonProperty(originalName) to properties that are renamed because its name is the same as its enclosing type.
  • New: Show/hide model warning due to renaming properties/classes whose name is a reserved keyword.
  • New: Support abstract class.
  • New: support complex type inheritance
  • New: Add attribute [MaxLength] for max length of string/byte[] properties.
  • Convert EDM.TIME in Odata v3 to TimeSpan.
  • Support multi schema.
  • Support multi containers in OData v3.

OData2Poco Packages

OData2Poco is available in three flavers:

  • A class library: support NET6/netstandard2.0/net461,download.
  • A Console tool: OData2Poco.CommandLine support net472 (a.k.a o2pgen), download.
  • A .Net Core Global tool dotnet-o2pgen support NET6, download.
  • Checolatey Console tool, download.

Install and Usage

1) OData2Poco.CommandLine o2pgen Console Cli

OData2Poco.CommandLine is a Console application (net472) named o2pgen.

It Can be installed from Nuget Gallery:

   Install-Package OData2Poco.CommandLine 

Executing o2pgen as MsBuild Target

Add the next xml code to the project.csproj:

<Target Name="Odata2PocoRun" BeforeTargets="CoreCompile">
               <options>-r http://services.odata.org/V4/Northwind/Northwind.svc/ -f Model\north.cs</options>
		<Message Text="Executing o2pgen.exe" Importance="High" />
		<Exec Condition="$(EnableCodeGeneration)
             Command="$(o2pgen)  $(options)" />

The attribute Options is the commandLine arguments. Modify the commandline options as you want. For more details read Getting Start.

Excuting o2pgen from Package Console Manager (PCM):

In visual studio 2019 and higher, o2pgen can be run directly from PowerShell Console (PCM). Its path is set during installation.

Check application is installed:

PM> o2pgen --version

Linux and Mac/OS x support

O2pgen cli can run on Linux and Mac/OS if Mono is installed.

2) OData2Poco global Console Cli (net6.0)

Install from nuget gallary, run the command:

dotnet tool install --global OData2Poco.dotnet.o2pgen

How to use:

Run the command:

   dotnet o2pgen -r http://services.odata.org/V4/Northwind/Northwind.svc/

For help type: dotnet o2pgen --help

Review Commandline option.

Executing the global tool as Msbuild Target

You can auto run dotnet o2pgen from within MsBuild Target and save code in the project folder.

Add the next Msbuild target to your project and modify command parameters as needed. When the property EnableCodeGeneration is set to false, no code is generated. The generated code is saved to file northwind.cs in the folder Model in the root of the project.

<Target Name="GenerateCode" BeforeTargets="CoreCompile">
		<Exec  Condition="$(EnableCodeGeneration)"
		  Command="dotnet o2pgen -r http://services.odata.org/V4/Northwind/Northwind.svc/ -f $(MSBuildProjectDirectory)\Model\northwind.cs -B">

3) OData2Poco Class library

Support NET6/netstandard2.0/net461. It can be installed from Nuget Gallery

     Install-Package OData2Poco

Try demo Application in NET6 Online

4) Checolatey Package

From Chocolatey Gallery:

 choco install odata2poco-commandline


Read the:Wiki


MIT License.

Release Notes



Thank you JetBrains for Resharper open source license

  • .NETFramework 4.6.1
    • Microsoft.Data.Edm (>= 5.8.5)
    • Microsoft.OData.Edm (>= 7.15.0)
    • Newtonsoft.Json (>= 13.0.3)
  • .NETFramework 4.7.2
    • Microsoft.Data.Edm (>= 5.8.5)
    • Microsoft.OData.Edm (>= 7.15.0)
    • Newtonsoft.Json (>= 13.0.3)
  • .NETFramework 6.0
    • Microsoft.Data.Edm (>= 5.8.5)
    • Microsoft.OData.Edm (>= 7.15.0)
    • Newtonsoft.Json (>= 13.0.3)
  • .NETStandard 2.0
    • Microsoft.Data.Edm (>= 5.8.5)
    • Microsoft.OData.Edm (>= 7.15.0)
    • Newtonsoft.Json (>= 13.0.3)
  • .NETFramework 4.6.1:
  • .NETFramework 4.7.2:
  • .NETFramework 6.0:
  • .NETStandard 2.0:




Mohamed Hassan

Project URL





code-generation odata charp c# typescript ts dto poco AspNetWebApi WebApi


3 total downloads
0 downloads for version 6.0.0-dev-71
Download (265.82 KB)
Download symbols (116.1 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
6.0.0-dev-71 265.82 KB Mon, 29 May 2023 17:17:44 GMT 0
6.0.0-dev-70 265.94 KB Mon, 29 May 2023 16:45:20 GMT 0
6.0.0-dev-69 265.28 KB Sat, 27 May 2023 07:21:10 GMT 0
6.0.0-dev-68 265.37 KB Sat, 27 May 2023 07:04:01 GMT 0
6.0.0-dev-67 265.37 KB Fri, 26 May 2023 19:41:43 GMT 0
6.0.0-dev-66 265.36 KB Fri, 26 May 2023 19:25:19 GMT 0
5.1.0-dev-55 193.05 KB Mon, 22 May 2023 06:01:52 GMT 0
5.1.0-dev-54 193.01 KB Wed, 17 May 2023 21:44:55 GMT 0
5.1.0-dev-53 190.62 KB Tue, 09 May 2023 08:04:05 GMT 0
5.1.0-dev-52 189.52 KB Sun, 07 May 2023 07:57:38 GMT 0
5.1.0-dev-51 188.88 KB Thu, 04 May 2023 07:00:37 GMT 1
5.1.0-dev-50 188.8 KB Tue, 02 May 2023 05:25:26 GMT 1
5.1.0-dev-49 188.82 KB Tue, 02 May 2023 05:07:51 GMT 0
5.1.0-dev-48 188.07 KB Mon, 01 May 2023 21:30:37 GMT 0
5.1.0-dev-47 187.6 KB Thu, 27 Apr 2023 10:19:26 GMT 0
5.1.0-dev-46 188.08 KB Thu, 27 Apr 2023 07:05:49 GMT 0
5.1.0-dev-45 188.14 KB Wed, 26 Apr 2023 06:47:35 GMT 0
5.1.0-dev-43 187.24 KB Wed, 26 Apr 2023 00:58:36 GMT 0
5.1.0-dev-42 185.94 KB Tue, 25 Apr 2023 03:34:49 GMT 0
5.1.0-dev-41 185.91 KB Tue, 25 Apr 2023 02:43:10 GMT 0
5.1.0-dev-40 185.66 KB Mon, 24 Apr 2023 12:11:05 GMT 0
5.1.0-dev-36 173.53 KB Mon, 21 Nov 2022 10:42:32 GMT 0
5.1.0-dev-35 173.53 KB Fri, 18 Nov 2022 12:51:31 GMT 0
5.1.0-dev-34 170.6 KB Fri, 18 Nov 2022 07:56:27 GMT 1
5.1.0-dev-33 170.6 KB Tue, 18 Oct 2022 22:13:52 GMT 0