EFの関連エンティティに問題があります。遅延ロードの問題EF MVC
これは私のProductクラスである:
public class Product
{
public int Id { get; set; }
public int AtpID { get; set; }
public int SupplierID { get; set; }
public string AtpName { get; set; }
public string Name { get; set; }
public string ArticleNo { get; set; }
public string SupplierNo { get; set; }
public string AtpPrice { get; set; }
public string AtpStock { get; set; }
public string AtpDeliveryDays { get; set; }
public bool FitsAllCars { get; set; }
public int? CategoryId { get; set; }
public virtual ICollection<ProductReference> ProductReferences { get; set; }
public virtual ICollection<ProductDetail> ProductDetails { get; set; }
}
これはProductDetailsクラスです:
public class ProductDetail
{
public int Id { get; set; }
[ForeignKey("ProductId")]
public virtual Product Product { get; set; }
public int ProductId { get; set; }
public int ProductDetailTypeId { get; set; }
public int ProductDetailKeyId { get; set; }
public string AtpTextKey { get; set; }
public string AtpTextValue { get; set; }
public string TextKey { get; set; }
public string TextValue { get; set; }
public bool IsVisible { get; set; }
public bool Checked { get; set; }
}
問題は、あなたが添付で見ることができるようProductDetailsは、製品にロードされていないということですスクリーンショット、それは私にエラーを与える:
ProductReferencesが正しく読み込まれ、ProductDetailsのみでこの問題が発生します。 この問題で私を助けることができますか?私はこの問題を引き起こす原因を知りませんでした。 ありがとう!あなたが選択したとき
を選択してください。 –
あなたのお問い合わせはどこですか? –
関連するコレクションにアクセスしようとすると例外が発生していますか? –