我的EF代码第一个站点有两个类,我可以使用lazyloding从类Section_Translation转到类Section(即Section_Translations.Section.XXXX),但我不能从Section转到Section_Translation(即Section.Section_Translation .XXXX)我不知道我需要做什么才能允许我从Section到Section_Translation旅行。
Section.cs
using FFInfo.DAL.GeneralTranslationTables;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FFInfo.DAL.GeneralTables
{
[Table("Section")]
public class Section
{
[Key, Required, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Int16 SectionID { get; set; }
public Int64? LogoFileID { get; set; }
[Required, MaxLength(15), Column(TypeName = "varchar")]
public string RouteName { get; set; }
[Required, MaxLength(15), Column(TypeName = "varchar")]
public string SectionType { get; set; }
public virtual IList<Section_Translation> SectionTranslations { get; set; }
[ForeignKey("LogoFileID")]
public virtual File File { get; set; }
}
}
Section_Translation.cs
using FFInfo.DAL.GeneralTables;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FFInfo.DAL.GeneralTranslationTables
{
[Table("SectionTranslation")]
public class Section_Translation
{
[Key, Required, Column(Order = 0)]
public Int16 SectionID { get; set; }
[Key, Required, Column(Order = 1)]
public byte CultureCodeID { get; set; }
[Required]
public string SectionTitle { get; set; }
public string Synopsis { get; set; }
[ForeignKey("SectionID")]
public virtual Section Section { get; set; }
[ForeignKey("CultureID")]
public virtual CultureCode Culture { get; set; }
}
}
答案 0 :(得分:0)
与同事交谈时,似乎EF不允许像我希望的那样构建延迟加载。