Search code examples
entity-frameworkaspnetboilerplate

master details entities, aggregate root - Abp Core


what is the best way to create parent-child entities

e.g

 oreder-->details
 recipe-->ingredients
 car-->parts

the doc talks about "Agregate root" https://aspnetboilerplate.com/Pages/Documents/Entities#aggregateroot-class

Is there any example? does exist another way? any suggestion please?

isn't this enough? order entity:

....
...
..
[ForeignKey("OrderId")]
public virtual ICollection<OrderDetail> Details { get; set; }
....
...

Solution

  • that's it!

    public class Order : FullAuditedEntity
    {
        public virtual ICollection<OrderDetail> Details { get; set; }
    }
    
    public class OrderDetail : FullAuditedEntity
    {
        [ForeignKey("OrderId")]
        public virtual Order Order { get; set; }
        public int OrderId { get; set; }
    }