Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies To: # OData client v7 supported
OData Client V7
Install
There are 2 ways to download and install the OData CLI
dotnet global tool:
To install the latest release of the OData CLI Nuget Package, use the dotnet tool install command
dotnet tool install --global Microsoft.OData.CliDirect Download:
You can download the binary files from this GitHub Release and use them directly to generate code.
Synopsis
odata-cli [-h|--help] [--version] <command>
Description
odata-cli is a CLI tool that generates strongly-typed C# and Visual Basic client code for a specified OData service. It generates a DataServiceContext class to interact with the service and CLR types for each entity type and complex type in the service model.
Options
versionDisplays the version of the odata-cli
-h|--helpShows the command-line help
Commands
generate
It generates strongly typed C# and Visual Basic client code for a specified OData service.
Synopsis
odata-cli generate [options]
Options
--metadata-uri|-mThe URI of the metadata document. The value must be set to a valid service document URI or a local file path. Optional if config file is specified. If specified, it will take precedence over the value in config file.
--config-file|-cPath to the OData Connected Service config file.
--file-name|-fnThe name of the generated file. If not provided, then the default name 'Reference.cs/.vb' is used.
--custom-headers|-hHeaders that will get sent along with the request when fetching the metadata document from the service.
Format: Header1:HeaderValue, Header2:HeaderValue.--proxy|-pProxy settings.
Format: domain\\user:password@SERVER:PORT.--namespace-prefix|-nsThe namespace of the client code generated. Example:
NorthWindService.Clientor it could be a name related to the OData endpoint that you are generating code for.--enable-tracking|-etEnable entity and property tracking.
--upper-camel-case|-uccTransforms names (class and property names) to upper camel-case so that to better conform with C# naming conventions.
--internal|-iApplies the
internalclass modifier on generated classes instead ofpublicthereby making them invisible outside the assembly.omit-versioning-info|-viOmit runtime version and code generation timestamp from the generated files.
--multiple-filesSplit the generated classes into separate files instead of generating all the code in a single file.
--excluded-operation-imports|-eoiComma-separated list of the names of operation imports to exclude from the generated code. Example:
ExcludedOperationImport1, ExcludedOperationImport2.--excluded-bound-operations|-eboComma-separated list of the names of bound operations to exclude from the generated code. Example:
BoundOperation1, BoundOperation2.--excluded-schema-types|-estComma-separated list of the names of entity types to exclude from the generated code. Example:
EntityType1, EntityType2, EntityType3.--ignore-unexpected-elements|-iueThis flag indicates whether to ignore unexpected elements and attributes in the metadata document and generate the client code if any
--outputdir|-oFull path to output directory. This could be an empty directory or a directory with a .csproj/.vbproj file. This is a required option.
Examples
odata-cli generate -m "http://localhost/odata" -o "link-to-output-directory"
The metadata-uri could be a link to an OData endpoint or a link to an xml file in your local computer file system.
The output directory can be a link a to an empty folder or a link to a project folder (a folder with the .csproj file).