AUA Framework Training — Episode 10

Adding a New Entity: Teacher

Understanding Core Entity Architecture, Primary Keys, and Automatic Base Fields in AUA

Watch Video on YouTube

The Concept of Entity in AUA Framework

Entities sit at the heart of the AUA framework architecture. Each entity is defined by a class that encapsulates its properties, characteristics, and relationships with other entities. Every entity relies on an identifier that can be any allowed .NET data type, or even a composite primary key consisting of two or more data types combined.

Inheritance & Identifiers

  • Every entity inherits from the base DomainEntity class.
  • This base class automatically injects a primary key field called ID alongside audit/monitoring fields.
  • Primary keys can easily be configured for types other than int, such as long or custom combination keys.

Default Built-in Fields

By default, the framework automatically handles specific operational fields for each entity:

ID Field

The primary record identifier with customizable data types.

IsActive (bool)

Indicates whether the entity record is active or inactive in the system.

RegistrationDate

Automatically generated inside SQL Server to track creation time without manual payload entry.

2. Composite Primary Key Configuration (UserRoleConfig)

UserRoleConfig.cs

For intermediate join tables in Many-to-Many relationships, the single Id property is ignored, and a compound primary key is defined using multiple foreign keys.

public class UserRoleConfig : IEntityTypeConfiguration<UserRole>
{
    public void Configure(EntityTypeBuilder<UserRole> builder)
    {
        // Ignore default single Id property
        builder.Ignore(p => p.Id);

        // Define composite key combining AppUserId and RoleId
        builder.HasKey(p => new
        {
            p.AppUserId,
            p.RoleId
        });
    }
}
“
”
"If you think good architecture is expensive, try bad architecture."
AUA Framework Philosophy

Official Channels & Community

Connect with the AUA Framework ecosystem.

Episode 10 Completed Many-to-Many relationship