Entities

Design patterns and standard operating procedures when developing or modifying entities.

Defining a New Entity

  1. In Feds.Schemas/Entities, create a new directory with the entity name.

  2. Create a new interface that describes the abstract definition of the entity.

Abstract entity definitions must not include an ID field, or one-to-one foreign keys. The ID field is reuqired by IHasId.

  1. Create an implementation for the entity (a class definition).

Example

public interface IPotatoChip {
    public bool Salted { get; set; }
    public bool Ridges { get; set; }
    public string Flavor { get; set; }
}

public interface IHasBrand {
    public long BrandId { get; set; }
}

public sealed class PotatoChip : IPotatoChip, WithId, IHasBrand {
    [Key]
    public long Id { get; set; }
    
    [ForeignKey("Brands")]
    public long BrandId { get; set; }
    
    public bool Salted { get; set; }
    
    public bool Ridges { get; set; }
    
    public bool Flavor { get; set; }
}

Last updated

Was this helpful?