I'm new to ASP.NET, and am wondering how to create CRUD pages for a Model which has Lists of other Models ? I followed this tutorial, which creates CRUD pages for a simple scenario in which the Model has primitive data types only. So as such, the DbContext created is only for that one Model used in the tutorial. But what if I have two Models which have a One-to-Many relationship between them, such as the following scenario ?
public class Player
{
public string name {get; set;}
public int age {get; set;}
public double salary {get; set;}
public string gender {get; set;}
public DateTime contractSignDate {get; set;}
}
public class Team
{
public string teamName {get; set;}
public string sportPlayed {get; set;}
public List<Player> players {get; set;}
}
If I want to create CRUD pages for the Team Model, the DbContext I make for it refers to that Model only. In fact, VS2013's scaffolding engine doesn't even both with the players
List and simply ignores it outright.
How to solve this ?
This is the DbContext I made for the Team Model:
public class TeamDBContext : DbContext
{
public DbSet<Team> Teams { get; set; }
}