Now that we have built our main entity skeleton we need to create some relationships between them. We want to be able to do stuff like retrieving an
Item, browsing to their related
Comments, then getting the
ApplicationUser for each one of them, and also the other way around. We can easily do that by implementing a set of related entity properties: EF will load them on demand using its default lazy-load retrieval feature.
The first thing we'll do is to add a new region to our
Item class, containing two new properties:
#region Related Properties /// <summary> /// Current Item's Author: this property will be loaded on first use using EF's Lazy-Loading feature. /// </summary> [ForeignKey("UserId")] public virtual ApplicationUser ...