Additional property with foreign key list

asp.net-core c# entity-framework-core

Accepted Answer

If Person had a lot of events, I would organize my person class as follows.

public class Person
{
    public int Id { get; set; }

    // each person have many events
    public List<EventRelation> Events { get; set; }
}

public class EventRelation
{
    public int Id { get; set; }

    public Events Event { get; set; }

    // Person Id forgen Key
    public int Person_Id { get; set; }

    // Events Id forgen Key
    public int Event_Id { get; set; }
}


public class Events
{
    public int Id { get; set; }

    public string EventType { get; set; }

}
2
2/21/2019 9:27:58 PM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow