asp.net mvc - EF6 Code First MVC Related Entity null -


i have these 2 classes:

public class players {     [key]     public int id { get; set; }     public string playername { get; set; }      public virtual icollection<resultitems> resultitems { get; set; } }  public class resultitems {     [key]     public int id { get; set; }     public int resultsid { get; set; }     public results results { get; set; }     public int position { get; set; }     public int playerid { get; set; }     public players player { get; set; }     public double cash { get; set; }     public int points { get; set; } } 

you'll see here database populating nice enter resultitems:

screenshot

however, when page loads, , loop through model create table of data, player entity null:

screenshot

can me understand why isn't loading? appreciated.

thanks,

paul.

you need add virtual keyword public players player or can db.resultitems.include("player").tolist()


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -