0

これはおそらく非常に難解な質問だと思いますが、ルックアップ テーブルを表すエンティティにはナビゲーション プロパティが必要ですか?

例えば

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; }
}

また、上記の例では、AccreditingAgency に State ナビゲーション プロパティを含める必要がありますか?

実際、ナビゲーション プロパティはいつ使用する必要があるのでしょうか。

明確にしていただきありがとうございます。

4

1 に答える 1

0

ナビゲーション プロパティは、純粋にユーザーの利益のために存在します。

州内のすべての認定機関を見つけられるようにしたい場合は、最初の nav プロパティを含めます。

認定機関の状態を知りたい場合は、2 番目のナビゲーション プロパティを含めます。

これらのいずれかを本当に知りたくない場合は、2 つのエンティティがまったくリンクされていない可能性があります。

于 2012-07-12T20:06:01.467 に答える