Kontent.Ai.ModelGenerator.Core
10.0.0
See the version list below for details.
dotnet add package Kontent.Ai.ModelGenerator.Core --version 10.0.0
NuGet\Install-Package Kontent.Ai.ModelGenerator.Core -Version 10.0.0
<PackageReference Include="Kontent.Ai.ModelGenerator.Core" Version="10.0.0" />
<PackageVersion Include="Kontent.Ai.ModelGenerator.Core" Version="10.0.0" />
<PackageReference Include="Kontent.Ai.ModelGenerator.Core" />
paket add Kontent.Ai.ModelGenerator.Core --version 10.0.0
#r "nuget: Kontent.Ai.ModelGenerator.Core, 10.0.0"
#:package Kontent.Ai.ModelGenerator.Core@10.0.0
#addin nuget:?package=Kontent.Ai.ModelGenerator.Core&version=10.0.0
#tool nuget:?package=Kontent.Ai.ModelGenerator.Core&version=10.0.0
Kontent.ai model generator utility for .NET
This utility generates strongly-typed record-based models for the Kontent.ai Delivery SDK for .NET (v19+).
This version targets the modern Delivery SDK (v19+) only. If you need to generate models for the legacy Delivery SDK (v18.x and earlier), the Management SDK, or Extended Delivery, use the previous stable release.
What's New in Updated Delivery Models
The generated models use modern C# features and patterns:
- Records - Immutable
recordtypes with{ get; init; }accessors - Modern types -
RichTextContent,Asset,TaxonomyTerm,IEmbeddedContent - Partial records - Easily extendable without modifying generated code
ContentTypeCodenameattribute - For source-generated TypeProvider discovery
Installation & Usage
.NET Tool (Recommended)
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>"] \
[--baseclass "<base-class-name>"]
Local Tool
dotnet new tool-manifest
dotnet tool install Kontent.Ai.ModelGenerator
dotnet tool run KontentModelGenerator --environmentId "<environmentId>" \
[--namespace "<custom-namespace>"] \
[--outputdir "<output-directory>"] \
[--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
<details> <summary>Building a self-contained binary for a specific platform</summary>
- Clone the repository
- Navigate to
src/Kontent.Ai.ModelGenerator dotnet build -r <RID>to build (see the list of all RIDs)dotnet publish -c release -r <RID>to publish
</details>
Parameters
| Short key | Long key | Required | Default value | Description |
|---|---|---|---|---|
-i |
--environmentId |
Yes | null |
A GUID that can be found in Kontent.ai → Environment settings → Environment ID |
-n |
--namespace |
No | KontentAiModels |
A name of the C# namespace |
-o |
--outputdir |
No | ./ |
An output folder path |
-t |
--withtypeprovider |
No | false |
(Obsolete) TypeProvider is now source-generated by the Delivery SDK. |
-b |
--baseclass |
No | null |
If provided, a base class type will be created and all generated classes will derive from it via partial extender classes |
CLI Syntax
Short keys such as -n "MyModels" are interchangeable with the long keys --namespace "MyModels". Other possible syntax is -n=MyModels or --namespace=MyModels. Parameter values are case-insensitive. 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):
Command-line arguments:
--DeliveryOptions:UseSecureAccess true --DeliveryOptions:SecureAccessApiKey <SecuredApiKey>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.Attributes;
using Kontent.Ai.Delivery.ContentItems;
using Kontent.Ai.Delivery.ContentItems.RichText;
using Kontent.Ai.Delivery.SharedModels;
namespace KontentAiModels;
[ContentTypeCodename("article")]
public partial record Article
{
public const string BodyCopyCodename = "body_copy";
public const string CustomTrackingCodeCodename = "custom_tracking_code";
public const string PersonasCodename = "personas";
public const string PostDateCodename = "post_date";
public const string RelatedArticlesCodename = "related_articles";
public const string TeaserImageCodename = "teaser_image";
public const string TitleCodename = "title";
public const string UrlPatternCodename = "url_pattern";
[JsonPropertyName("body_copy")]
public RichTextContent? BodyCopy { get; init; }
[JsonPropertyName("custom_tracking_code")]
public string? CustomTrackingCode { get; init; }
[JsonPropertyName("personas")]
public IEnumerable<TaxonomyTerm>? Personas { get; init; }
[JsonPropertyName("post_date")]
public DateTimeContent? PostDate { get; init; }
[JsonPropertyName("related_articles")]
public IEnumerable<IEmbeddedContent>? RelatedArticles { get; init; }
[JsonPropertyName("teaser_image")]
public IEnumerable<Asset>? TeaserImage { get; init; }
[JsonPropertyName("title")]
public string? Title { get; init; }
[JsonPropertyName("url_pattern")]
public string? UrlPattern { 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;
[ContentTypeCodename("article")]
public partial record Article
{
public const string TitleCodename = "title";
// ... other constants and properties
[JsonPropertyName("title")]
public string? Title { get; init; }
}
Your custom file: Article.Custom.cs (your customizations)
namespace KontentAiModels;
public partial record Article
{
// Add computed properties
public string Slug => Title?.ToLowerInvariant().Replace(" ", "-") ?? string.Empty;
// Add custom methods
public bool IsPublished() => PostDate is { DateTime: var dt } && dt <= 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 version supports the modern Delivery SDK (v19+) only. For other use cases, use the previous stable release:
- Legacy Delivery SDK (v18.x and earlier) models
- Management SDK models
- Extended Delivery models
Feedback & Contributing
Found a bug or have a feature request? Open an issue. Pull requests are welcome!
Wall of Fame
We would like to express our thanks to the following people who contributed and made the project possible:
License
| Product | Versions 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. |
-
net8.0
- Kontent.Ai.Delivery (>= 19.0.0)
- Kontent.Ai.Delivery.Abstractions (>= 19.0.0)
- Microsoft.CodeAnalysis (>= 4.13.0)
- Microsoft.Extensions.Options (>= 10.0.1)
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.2.0 | 103 | 5/5/2026 |
| 10.1.1 | 125 | 4/23/2026 |
| 10.1.0 | 116 | 4/21/2026 |
| 10.0.0 | 107 | 4/19/2026 |
| 10.0.0-beta-5 | 118 | 3/3/2026 |
| 10.0.0-beta-4 | 113 | 3/3/2026 |
| 10.0.0-beta-3 | 108 | 2/20/2026 |
| 10.0.0-beta-2 | 122 | 1/11/2026 |
| 10.0.0-beta | 217 | 10/26/2025 |
| 9.0.0 | 984 | 4/8/2025 |
| 8.4.0 | 17,097 | 12/12/2023 |
| 8.3.3 | 1,720 | 6/4/2023 |
| 8.3.2 | 279 | 5/18/2023 |
| 8.3.1 | 291 | 5/5/2023 |
| 8.3.0 | 327 | 4/20/2023 |
| 8.3.0-beta.6 | 210 | 4/13/2023 |
| 8.3.0-beta.3 | 206 | 2/16/2023 |
| 8.3.0-beta.2 | 215 | 2/16/2023 |
| 8.3.0-beta.1 | 205 | 2/16/2023 |
| 8.2.0 | 387 | 2/9/2023 |