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:
however, when page loads, , loop through model create table of data, player entity null:
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
Post a Comment