Creating Phone Entity

Let's start by creating a new Entity, Phone in .Core project:

public class Phone : CreationAuditedEntity<long>

    public virtual Person Person { get; set; }
    public virtual int PersonId { get; set; }

    public virtual PhoneType Type { get; set; }

    public virtual string Number { get; set; }

And PhoneConsts in Core.Shared project:

public class PhoneConsts
    public const int MaxNumberLength = 16;

Phone entities are stored in PbPhones table. Its primary key is long and it inherits creation auditing properties. It has a reference to Person entity which owns the phone number.

We added a Phones collection to the People:

public class Person : FullAuditedEntity
    //...other properties

    public virtual ICollection<Phone> Phones { get; set; }

We have a PhoneType enum in .Core.Shared project as shown below:

public enum PhoneType : byte

Lastly, we're also adding a DbSet property for Phone to our DbContext:

public virtual DbSet<Phone> Phones { get; set; }


In this document