locked
Releation Between Two Columns With Multiple Object RRS feed

  • Question

  • User1699480839 posted

    Hello everyone;

    EFCore has some confusions with my schema and I con not figure out how to solve. 

    WebSiteModel has two property; 

    public virtual ICollection<IconLinkModel> NavBarUpperLeftItems { get; set; }
    public virtual ICollection<IconLinkModel> NavBarItems { get; set; }

    Normally, I should have 4 items in NavBarUpperLeftItems and 1 item in NavBarItems. 

    When I fetch data like that;

    website = context
    .WebSites
    .Include(x => x.NavBarUpperLeftItems)
    .Include(x => x.NavBarItems)
    .FirstOrDefault(x => x.Domain == domain);

    NavBarUpperLeftItems is empty and all items comes in NavBarItems.

    Is that a normal behaviour, how can I avoid that?

    PS: I am using MySQL, Pomelo driver and dotnetcore 5. 

    Thanks. 

    Sunday, January 17, 2021 9:24 AM

All replies

  • User1699480839 posted

    I solved the problem by adding foreign key. Thanks 

    Sunday, January 17, 2021 11:41 AM