データ注釈を使用するときに何か不足しています。データ注釈が1対多のオブジェクト参照を作成しない
これが私の最初のクラス
[Table("PriceFeed")]
public class PriceFeed : History
{
public PriceFeed()
{
this.Votes = new List<PriceVote>();
this.History = new List<PriceFeed__History>();
}
[Key]
public long Id { get; set; }
[ForeignKey("Store")]
public long Store_Id { get; set; }
[ForeignKey("Item")]
public long Item_Id { get; set; }
[Required]
public decimal Price { get; set; }
public Store Store { get; set; }
public Item Item { get; set; }
public virtual ICollection<PriceFeed__History> History { get; set; }
}
であると私はアドオンの移行を実行すると、これは私がPriceFeedにアクセスしようとすると、それが正しく、データベースを作成しますが、私の第二のクラス
[Table("PriceFeed__History")]
public class PriceFeed__History : History
{
[Key]
public long Id { get; set; }
[ForeignKey("PriceFeed")]
public long PriceFeed_Id { get; set; }
[Required]
public decimal Price { get; set; }
public virtual PriceFeed PriceFeed { get; set; }
}
です。歴史それは私にエラーを与える
{"Message":"An error has occurred.","ExceptionMessage":"A specified Include path is not valid. The EntityType 'Verdinhas.Web.Contexts.PriceFeed' does not declare a navigation property with the name 'PriceFeed__History'."
私はいつもAPI Fluentで働いて、自分で打ち込んだth
.Entity<Student>()
.HasRequired<Standard>(s => s.Standard)
.WithMany(s => s.Students)
.HasForeignKey(s => s.StdId);
しかし、今、私はデータアノテーションを使用していると私は、マイグレーションを生成するとき、それは上記のような「withmany」を作成しないような電子コード。
私は間違っていますか?
例外メッセージは、表示していないクエリ(Includeを含む)からのものです。 –
私はリポジトリパターンを使用していて、PriceRepository.Get(x => x.Id == priceId、null、 "Store、Item、PriceFeed__History")のような履歴テーブルを含むpricerepositoryを呼び出しています。 –
さて、そこには、プロパティ名、たとえば"店舗、アイテム、歴史" –