I'm trying populate an object using EF Core that has an inverse relationship. I have a table "Party" with a child table "PartyEntertainment" that has a collection of entertainers. There is a field in Entertainment called EntertainmentTypeId that references a lookup table EntertainmentType (-> EntertainmentTypeId int, EntertainmentTypeDisplay varchar(16)) . I populate the data using:
var party = await _context.Party .Include(h => h.Host) .Include(t => t.PartyTopic) .Include(e => e.PartyEntertainment) .Include(g => g.GuestList) .FirstOrDefaultAsync();
The PartyEntertainment object has a property of type EntertainmentType for the inverse relationhip on EntertaimentType object, but it is null. How can I populate this?
In my View I want to show it using
@foreach (var e in party.PartyEntertainment) {<div><span>@e.Name</span><span>@e.EntertainmentType.EntertainmentTypeDisplay</span><span>@e.Description</span></div> }