Contentstack .NET Model Generator

This utility is used to generate models based on content types in stack.


To install Contenstack Model Generator, run following command:

dotnet tool install --global contentstack.model.generator --version 0.4.1

In case you need to update your Model Generator, use the following:

dotnet tool update --global contentstack.model.generator --version 0.4.1

Note: In the above command, if you skip version, you will still be able to download the latest version of the Model Generator.

Use the Model Generator

Once you install Contentstack Model Generator utility, run --help to view available commands. The following table lists the shortcut keys for running specific operations:

Short keyLong KeyDescription
-a--api-keyThe Stack API key for the Content Management API



The Authtoken for the Content Management API
-e--endpointThe Contentstack Host for the Content Management API
-n--namespaceThe namespace the classes should be created in
-f--forceAutomatically overwrite files that already exist
-m--modular-block-prefixThe Modular block Class Prefix
-g--group-prefixThe Group Class Prefix
-p--pathPath to the file or directory to create files in

Example 1

To create classes in the current directory run the following command:

contentstack.model.generator -a <stack_api_key> -A <authtoken>

Example 2

To create classes in a specific path, run the following command:

contentstack.model.generator -a <stack_api_key> -A <authtoken> -p /User/xxx/Desktop

Example 3

To create classes with namespace, run the following command:

contentstack.model.generator -a <stack_api_key> -A <authtoken> -n YourProject.Models


For more details, refer to our GitHub page.

More resources

Was this article helpful?