How best to store a list of objects belonging to a user in ASP.NET MVC?

I’m writing an ASP.NET MVC web application that tracks characters from a game. We’re using a code-first approach to make the database. One of the use cases is that the items belonging to each character be stored so they can be displayed in an inventory view.

I’m fairly new to ASP.NET MVC and I’m wondering what the best way is to store item objects that belong to the user? At the moment I have a lists of each type of item (see below). Will this approach work with Entity Framework?

public class Character : ParentClass
{
    public List<Skill> Skills { get; set; }
    public List<Armour> Armours { get; set; }
    public List<Weapon> Weapons { get; set; }
    public List<MagicItem> MagicItems { get; set; }
    public List<AdventuringGear> AdventuringGears { get; set; }
}

Will Entity Framework automatically keep track of the foreign keys that link, say, a sword to the character?

Thanks in advance.

Answer

At the moment I have a lists of each type of item (see below). Will this approach work with Entity Framework?

Yes. Although the preferred idiom for EF is

public virtual ICollection<Skill> Skills { get; } = new HashSet<Skill>();

virtual to enable Lazy Loading, and a HashSet as there’s no inherent ordering in the database, and initialized to an empty collection for convenience.

Will Entity Framework automatically keep track of the foreign keys that link, say, a sword to the character?

Yes. If you don’t model Skill with a CharacterId foreign key property, EF will create one in the database behind the scenes.