I know this is probably a very obtuse question, but do entities which represent a lookup table need navigation properties?
For example
public class State
{
public int StateId { get; set; }
public string StateName { get; set; }
public string StateAbbr { get; set; }
public virtual ICollection<AccreditingAgency> AccreditingAgencies { get; set; }
}
public class AccreditingAgency
{
public int AccreditingAgencyId { get; set; }
public string AgencyName { get; set; }
public string AgencyAddress { get; set; }
public string AgencyCity { get; set; }
public int StateId { get; set; }
public string AgencyZipCode { get; set; }
public string AgencyWebsite { get; set; }
public virtual State State { get; set; }
}
Also, in the example above, should I even have a State navigation property in AccreditingAgency?
In fact, when should a navigation property be used?
Thanks for any clarification.
Navigation properties are purely there for your benefit.
If you want to be able to find out all Accrediting agencies in a state include the first nav property.
If you want to find out what state an accrediting agency is in include the second navigation property.
If you dont really want to know either of these then prehaps the two entities shoudlnt be linked at all.