astral-api/Astral.Core/Exceptions/PrimaryKeyMissingException.cs

29 lines
916 B
C#
Raw Permalink Normal View History

2024-12-11 21:36:30 +01:00
// <copyright file="PrimaryKeyMissingException.cs" company="alveus.dev">
// Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License.
// </copyright>
using Astral.Core.Attributes.EntityAnnotation;
namespace Astral.Core.Exceptions;
/// <summary>
/// Thrown if an entity is missing a property with <see cref="PrimaryKeyAttribute" />.
/// </summary>
public class PrimaryKeyMissingException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="PrimaryKeyMissingException" /> class.
/// </summary>
/// <param name="entityType">The entity causing the exception.</param>
public PrimaryKeyMissingException(Type entityType)
: base($"Entity '{entityType}' is missing a property with a PrimaryKey.")
{
EntityType = entityType;
}
/// <summary>
/// The entity type.
/// </summary>
public Type EntityType { get; set; }
}