-1

現在、私はProgramming Entity Framework:Code Firstをフォローしています。ここで、作成者はこれらのモデルクラスを作成しました。

namespace Model
{
    public class Destination
    {
        public int DestinationID { get; set; }
        public string Name { get; set; }
        public string Country { get; set; }
        public string Description { get; set; }
        public byte[] Photo { get; set; }
        public List<Lodging> Lodgings { get; set; }
    }

    public class Lodging
    {
        public int LodgingID { get; set; }
        public string Name { get; set; }
        public string Owner { get; set; }
        public bool IsResort { get; set; }
        public Destination Destination { get; set; }
    }
}

そして、自動生成されたデータベースにテーブル内で呼び出される外部キーがあることを示しました。しかし、私の場合、問題は外部キーではなく通常のintとして作成されていることです。Destination_DestinationIDLodgings

私はEF5を使用していますが、この本はEF4.1を使用していると思いますが、これがその違いの原因ですか?

4

1 に答える 1

0

コードをコピーし、EF Code First 5 を使用しています。生成された Destination_DestinationId は実際には外部キーです。問題は最初のコードではありませんが、Visual Studio Server Explorer ではそれが表示されません。データベース関連のタスクには SQL Server Management Studio を使用することを好み、列が実際には灰色のキーを持つ外部キーであることを示します。アイコン。

于 2013-03-01T22:57:37.470 に答える