テーブルの場所からの外部キーとして「場所」を持つ次のモデルがあります
public class Restaurant
{
public int id{ get; set; }
public string name{ get; set; }
public ICollection<Locations> locations { get; set; }
}
null
モデルレストランを初期化するたびに、属性の例を呼び出す前にロケーションDBコンテキストを呼び出した場合を除いて、ロケーションが設定されるのはなぜですか。
var t = db.Restaurant.First(); // the locations attribute is null
db.Locations.First(); // calling the locations db context
t; // now t.locations has one record without adding anything just loading the DB
場所を呼び出すたびにクエリを自動的に開始するにはどうすればよいですか...