Entities

Entities are uniquely identifiable by a combination of one or more attributes or properties

Entities are distinct from other domain concepts such as Value Objects and Aggregates. Value Objects are immutable objects whose equality is based on their attribute values, while Aggregates are groups of related entities and value objects treated as a single unit for consistency and transactional boundaries.

Eiffel.Modelling.Abstractions NuGet package contains base Entity class. By using abstract Entity class you can define your entities.

/// <summary>
/// Base entity class
/// </summary>
/// <typeparam name="TKey">The type of database primary key</typeparam>
public abstract class EntityBase<TKey>
    where TKey : struct, IEquatable<TKey>
{
    /// <summary>
    /// Primary key
    /// </summary>
    [Key]
    public TKey Id { get; internal set; }
}

Entities are typically implemented as classes in object-oriented programming languages, and their properties and behavior reflect the essential attributes and operations of the corresponding real-world objects they represent in the domain.

Example Passenger entity with properties.

public class Passenger : EnttiyBase<long>
{
    public string Name { get; private set; }

    public string Surname { get; private set; }
}

Last updated