> 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/17.latest/reference/models/ai-entity-version.md).

# AIEntityVersion

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/17.latest/reference/services/ai-entity-version-service.md) - Version service
* [Version History Concept](/ai-in-umbraco/17.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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
