Kontent.Ai.ModelGenerator.Core 10.0.0-beta-2

This is a prerelease version of Kontent.Ai.ModelGenerator.Core.
dotnet add package Kontent.Ai.ModelGenerator.Core --version 10.0.0-beta-2
                    
NuGet\Install-Package Kontent.Ai.ModelGenerator.Core -Version 10.0.0-beta-2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kontent.Ai.ModelGenerator.Core" Version="10.0.0-beta-2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kontent.Ai.ModelGenerator.Core" Version="10.0.0-beta-2" />
                    
Directory.Packages.props
<PackageReference Include="Kontent.Ai.ModelGenerator.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kontent.Ai.ModelGenerator.Core --version 10.0.0-beta-2
                    
#r "nuget: Kontent.Ai.ModelGenerator.Core, 10.0.0-beta-2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kontent.Ai.ModelGenerator.Core@10.0.0-beta-2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kontent.Ai.ModelGenerator.Core&version=10.0.0-beta-2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Kontent.Ai.ModelGenerator.Core&version=10.0.0-beta-2&prerelease
                    
Install as a Cake Tool

Kontent.ai model generator utility for .NET

Build & Test codecov Stack Overflow Discord

⚠️ BETA VERSION - Modern Delivery SDK ONLY

This beta version ONLY works with the modernized Kontent.ai Delivery SDK for .NET (v19.0.0-beta-3 and higher).

What this version supports:

  • Modern Delivery SDK (v19+) - Generates record-based models with modern types

What this version does NOT support:

Need the old version? If you're using the legacy Delivery SDK (v18.x), Management SDK, or Extended Delivery models, please use the previous stable release from the releases page.


This utility generates strongly-typed record-based models for the modern Kontent.ai Delivery SDK for .NET (v19+).

What's New in Modern Delivery Models

The generated models use modern C# features and patterns:

  • Records - Immutable record types with { get; init; } accessors
  • File-scoped namespaces - Clean, modern C# syntax
  • JSON attributes - [JsonPropertyName] for explicit property mapping
  • Modern types - RichTextContent, Asset, TaxonomyTerm, IEmbeddedContent
  • Single file per model - No .Generated.cs split files
  • Partial records - Easily extendable without modifying generated code
  • IElementsModel interface - For type-safe element access

Installation & Usage

The recommended way of obtaining this tool is installing it as a .NET Tool. You can install it as a global tool or per project as a local tool.

Global Tool
  • dotnet tool install -g Kontent.Ai.ModelGenerator
  • KontentModelGenerator --environmentid "<environmentId>" [--namespace "<custom-namespace>"] [--outputdir "<output-directory>"] [--withtypeprovider <True|False>] [--baseclass "<base-class-name>"]
Local Tool
  • dotnet new tool-manifest to initialize the tools manifest (if you haven't done that already)
  • dotnet tool install Kontent.Ai.ModelGenerator (to install the latest version
  • dotnet tool run KontentModelGenerator --environmentId "<environmentId>" [--namespace "<custom-namespace>"] [--outputdir "<output-directory>"] [--withtypeprovider <True|False>] [--baseclass "<base-class-name>"]

Standalone apps for Windows 🗔, Linux 🐧, macOS 🍎

Self-contained apps are an ideal choice for machines without any version of .NET installed.

Latest release: Download

  • KontentModelGenerator --environmentId "<environmentId>" [--namespace "<custom-namespace>"] [--outputdir "<output-directory>"] [--withtypeprovider <True|False>] [--baseclass "<base-class-name>"]

To learn how to generate executables for your favorite target platform, follow the steps in the docs.

Parameters

Short key Long key Required Default value Description
-i --environmentId True null A GUID that can be found in Kontent.ai → Environment settings → Environment ID
-n --namespace False KontentAiModels A name of the C# namespace
-o --outputdir False \. An output folder path
-t --withtypeprovider False true Indicates whether the CustomTypeProvider class should be generated for model binding
-b --baseclass False null If provided, a base class type will be created and all generated classes will derive from that base class via partial extender classes

CLI Syntax

Short keys such as -t true are interchangable with the long keys --withtypeprovider true. Other possible syntax is -t=true or --withtypeprovider=true. Parameter values are case-insensitive, so you can use both -t=true and -t=True. To see all aspects of the syntax, see the MS docs.

Config file

These parameters can also be set via the appSettings.json file located in the same directory as the executable file. Command-line parameters always take precedence.

Advanced configuration (Preview API, Secure API)

There are two ways of configuring advanced Delivery SDK options (such as secure API access, preview API access, and others):

  1. Command-line arguments --DeliveryOptions:UseSecureAccess true --DeliveryOptions:SecureAccessApiKey <SecuredApiKey> (syntax)

  2. appSettings.json - suitable for the standalone app release

Generated Model Example

Generated file: Article.cs

// <auto-generated>
// This code was generated by Kontent.ai model generator tool
// (see https://github.com/kontent-ai/model-generator-net).
//
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
// To extend this record, create a separate partial record with the same name.
// </auto-generated>

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Kontent.Ai.Delivery.Abstractions;
using Kontent.Ai.Delivery.ContentItems;
using Kontent.Ai.Delivery.ContentItems.RichText;
using Kontent.Ai.Delivery.SharedModels;

namespace KontentAiModels;

public partial record Article
{
    [JsonPropertyName("title")]
    public string Title { get; init; } = default!;

    [JsonPropertyName("body_copy")]
    public RichTextContent BodyCopy { get; init; } = default!;

    [JsonPropertyName("post_date")]
    public DateTimeContent PostDate { get; init; }

    [JsonPropertyName("teaser_image")]
    public IEnumerable<Asset> TeaserImage { get; init; } = default!;

    [JsonPropertyName("related_articles")]
    public IEnumerable<IEmbeddedContent> RelatedArticles { get; init; } = default!;

    [JsonPropertyName("personas")]
    public IEnumerable<TaxonomyTerm> Personas { get; init; } = default!;

    [JsonPropertyName("url_pattern")]
    public string UrlPattern { get; init; } = default!;

    [JsonPropertyName("custom_tracking_code")]
    public string? CustomTrackingCode { get; init; }
}

Customizing Generated Models

Since the generated models are partial records, you can extend them by creating your own partial record file:

Generated file: Article.cs (auto-generated)

namespace KontentAiModels;

public partial record Article
{
    [JsonPropertyName("title")]
    public string Title { get; init; } = default!;
    // ... other properties
}

Your custom file: Article.Custom.cs (your customizations)

namespace KontentAiModels;

public partial record Article
{
    // Add computed properties
    public string Slug => Title.ToLowerInvariant().Replace(" ", "-");

    // Add custom methods
    public bool IsPublished() => PostDate.HasValue && PostDate.Value <= DateTime.Now;

    // Add validation
    public bool IsValid() => !string.IsNullOrEmpty(Title) && BodyCopy != null;
}

The generator creates the base model, and you maintain customizations in separate files that won't be overwritten.

Need Management SDK or Legacy Delivery SDK Support?

This beta version only supports the modern Delivery SDK (v19+).

For other use cases, please use the previous stable release:

  • Legacy Delivery SDK (v18.x and earlier) models
  • Management SDK models
  • Extended Delivery models

Feedback & Contributing

Check out the contributing page to see the best places to file issues, start discussions and begin contributing.

Wall of Fame

We would like to express our thanks to the following people who contributed and made the project possible:

Would you like to become a hero too? Pick an issue and send us a pull request!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0-beta-2 91 1/11/2026
10.0.0-beta 192 10/26/2025
9.0.0 520 4/8/2025
8.4.0 15,782 12/12/2023
8.3.3 1,685 6/4/2023
8.3.2 255 5/18/2023
8.3.1 266 5/5/2023
8.3.0 300 4/20/2023
8.3.0-beta.6 184 4/13/2023
8.3.0-beta.3 182 2/16/2023
8.3.0-beta.2 186 2/16/2023
8.3.0-beta.1 184 2/16/2023
8.2.0 370 2/9/2023
8.1.1 3,985 1/5/2023
8.1.1-beta.4 199 10/27/2022
8.1.1-beta.3 201 10/27/2022
8.1.1-beta.2 203 10/27/2022
8.1.1-beta.1 197 10/27/2022
8.1.1-beta.0 206 10/27/2022
8.1.0 531 10/27/2022
Loading failed