現在、私は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_DestinationID
Lodgings
私はEF5を使用していますが、この本はEF4.1を使用していると思いますが、これがその違いの原因ですか?