> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/ai-in-umbraco/19.latest/reference/models/ai-entity-version.md).

# AIEntityVersion

Model representing an entity version history record.

Represents a version history record for a versioned AI entity.

## Namespace

```csharp
using Umbraco.AI.Core.Versioning;
```

## Definition

{% code title="AIEntityVersion" %}

```csharp
public sealed class AIEntityVersion
{
    public Guid Id { get; init; }
    public Guid EntityId { get; init; }
    public string EntityType { get; init; } = string.Empty;
    public int Version { get; init; }
    public string Snapshot { get; init; } = string.Empty;
    public DateTime DateCreated { get; init; }
    public Guid? CreatedByUserId { get; init; }
    public string? ChangeDescription { get; init; }
}
```

{% endcode %}

## Properties

| Property            | Type       | Description                        |
| ------------------- | ---------- | ---------------------------------- |
| `Id`                | `Guid`     | Version record identifier          |
| `EntityId`          | `Guid`     | ID of the versioned entity         |
| `EntityType`        | `string`   | Type discriminator                 |
| `Version`           | `int`      | Sequential version number          |
| `Snapshot`          | `string`   | JSON serialization of entity state |
| `DateCreated`       | `DateTime` | When this version was created      |
| `CreatedByUserId`   | `Guid?`    | User who created this version      |
| `ChangeDescription` | `string?`  | Optional description of changes    |

## Entity Types

| Type String    | Entity         | Package           |
| -------------- | -------------- | ----------------- |
| `"connection"` | `AIConnection` | Umbraco.AI        |
| `"profile"`    | `AIProfile`    | Umbraco.AI        |
| `"context"`    | `AIContext`    | Umbraco.AI        |
| `"guardrail"`  | `AIGuardrail`  | Umbraco.AI        |
| `"prompt"`     | `AIPrompt`     | Umbraco.AI.Prompt |
| `"agent"`      | `AIAgent`      | Umbraco.AI.Agent  |

## Example

{% code title="Example" %}

```csharp
// Getting version history
var (versions, total) = await _versionService.GetVersionHistoryAsync(
    profileId,
    "profile");

foreach (var version in versions)
{
    Console.WriteLine($"v{version.Version} - {version.DateCreated}");
    if (!string.IsNullOrEmpty(version.ChangeDescription))
    {
        Console.WriteLine($"  {version.ChangeDescription}");
    }
}
```

{% endcode %}

***

## AIVersionComparison

Result of comparing two entity versions.

{% code title="AIVersionComparison" %}

```csharp
public sealed class AIVersionComparison
{
    public Guid EntityId { get; init; }
    public string EntityType { get; init; } = string.Empty;
    public int FromVersion { get; init; }
    public int ToVersion { get; init; }
    public IReadOnlyList<AIValueChange> Changes { get; init; } = Array.Empty<AIValueChange>();
}
```

{% endcode %}

***

## AIValueChange

Represents a single change between two versions.

{% code title="AIValueChange" %}

```csharp
public sealed class AIValueChange
{
    public string Path { get; init; } = string.Empty;
    public string? OldValue { get; init; }
    public string? NewValue { get; init; }
}
```

{% endcode %}

***

## AIVersionCleanupResult

Result of version cleanup operation.

{% code title="AIVersionCleanupResult" %}

```csharp
public sealed class AIVersionCleanupResult
{
    public int DeletedByAge { get; init; }
    public int DeletedByCount { get; init; }
    public int TotalDeleted => DeletedByAge + DeletedByCount;
    public int RemainingVersions { get; init; }
    public bool WasSkipped { get; init; }
    public string? SkipReason { get; init; }
}
```

{% endcode %}

***

## IAIVersionableEntity

Interface implemented by entities that support versioning.

{% code title="IAIVersionableEntity" %}

```csharp
public interface IAIVersionableEntity : IAIAuditableEntity
{
    int Version { get; }
}
```

{% endcode %}

## Related

* [IAIEntityVersionService](/ai-in-umbraco/19.latest/reference/services/ai-entity-version-service.md) - Version service
* [Version History Concept](/ai-in-umbraco/19.latest/concepts/versioning.md) - Versioning concepts


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/ai-in-umbraco/19.latest/reference/models/ai-entity-version.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
