Search code examples
entity-frameworkentityentity-relationshipconcept

Entity associations


i started to read Entity Framework Book. in first part of book it describes entity and object similarities and differents. it writes :

Each entity has associations with other entities.

what is the meaning of associations with other entities ? is that like relation ? associations in my language means something like community(!). so i can't Understand what does it mean.


Solution

  • Yes it means relation. Each entity can have association / relation to other entities which allows some advanced concepts like loading related entities by single query, building complex queries or loading realted entities on demand.

    Example:

    public class Order
    {
        public virtual ICollection<OrderItem> OrderItems { get; set; }
    }
    
    public class OrderItem
    {
        public virtual Order Order { get; set; }
    }
    

    Here we have two entities related in one-to-many relation. Both entities have navigation property to their related entities.