AUA Framework Training — Episode 6

Adding a New Entity (Student)

Mastering Entities, Inheritances, Default Monitoring Fields, and Configurations in AUA

Watch Video on YouTube

What is an Entity in AUA?

Entity is the main concept and sits at the heart of the AUA framework architecture. Each entity is defined by a class that contains its specific features and relationships with other entities.

Every entity requires an identifier (primary key) which can be any allowed .NET data type or a combination key made of two or more types.

Adding Entities & Default Fields

Each entity inherits from the DomainEntity base class. By default, three core monitoring fields are automatically added:

Id (Primary Key)

Defaults to int, but custom types (e.g., long) can be explicitly specified.

IsActive

Boolean flag (bool) indicating whether the entity record is active or inactive.

RegistrationDate

Automatically generated inside SQL Server upon creation; no manual filling required.

Entity Configurations & Optional Features

Fluent Configurations

Field Lengths & Compound Keys

A dedicated configuration class exists for each entity to specify field lengths and constraints. For compound keys (like AppUserId and RoleId in a UserRole entity), configurations map multi-column primary keys cleanly.

Custom Behaviors

Non-Identity & Logical Deletion

Entities can be configured without an identity key (where initial primary key values are manually passed to SQL Server) or customized without registering logical soft-deletion constraints depending on business needs.

Domain Entity Architecture & Primary Key Configuration

Student.cs & BaseEntities.cs

All entities in AUA inherit from DomainEntity. The primary key defaults to int, but can be explicitly customized to other types like long:

Default Int Primary Key
public class Student : DomainEntity
{
    public string FirstName { get; set; }

    public string LastName { get; set; }

    public int Age { get; set; }
}
Explicit Long Primary Key
public class Student : DomainEntity<long>
{
    public string FirstName { get; set; }

    public string LastName { get; set; }

    public int Age { get; set; }
}
Internal Base Classes (Framework Infrastructure)
// Base entity providing Primary Key (Id) and Active status
public class BaseDomainEntity<TPrimaryKey> : IDomainEntity<TPrimaryKey>
{
    public TPrimaryKey Id { get; set; }

    public bool IsActive { get; set; }
}

// Domain entity adding automatically handled Registration Date (RegDate)
public class DomainEntity<TPrimaryKey> : BaseDomainEntity<TPrimaryKey>, IAuditInfo
{
    public DateTime RegDate { get; set; }
}

1. Entity Field Length Configuration (StudentConfig)

StudentConfig.cs

Each domain entity has a dedicated configuration class implementing IEntityTypeConfiguration<T> to define field constraints and lengths using LengthConsts.

public class StudentConfig : IEntityTypeConfiguration<Student>
{
    public void Configure(EntityTypeBuilder<Student> builder)
    {
        builder
            .Property(p => p.FirstName)
            .HasMaxLength(LengthConsts.MaxStringLen50);

        builder
            .Property(p => p.LastName)
            .HasMaxLength(LengthConsts.MaxStringLen50);
    }
}
“
”
"If you think good architecture is expensive, try bad architecture."
AUA Framework Philosophy

Official Channels & Community

Connect with the AUA Framework ecosystem.

Episode 6 Completed Creating DTO-Mapping