实体框架 - 列名无效

时间:2014-07-10 12:33:48

标签: c# entity-framework entity-framework-6

我正在使用EF6,我收到错误列名“ContentArticleHOAsubdivisionId”无效。以下是相关模型,我试图将它们联系在一起:

public partial class ContentArticleHOAsubdivision
{
    public int Id { get; set; }
    public long ContentArticleId { get; set; }
    public short SubdivisionHOAId { get; set; }

    [ForeignKey("ContentArticleId")]
    public virtual ContentArticleHOA ContentArticleHOA { get; set; }
    public virtual ICollection<SubdivisionHOA> SubdivisionsHOA { get; set; }
}

public partial class SubdivisionHOA
{
    [Key, ForeignKey("TopTierDivisionHOA")]
    public short Id { get; set; }
    public string Name { get; set; }

    public int ContentArticleHOAsubdivisionId { get; set; }

    [ForeignKey("ContentArticleHOAsubdivisionId")]
    public virtual ContentArticleHOAsubdivision ContentArticleHOAsubdivision { get; set; }
    public virtual TopTierDivisionHOA TopTierDivisionHOA { get; set; }
}

我正在使用代码优先,当我尝试查询数据时会发生错误。这是完整的查询:

            query = context.ContentArticleHOA.Where(
                    c => c.ContentArticleHOAsubdivisions.Any(cs => cs.SubdivisionsHOA.Any(s => s.Name == subdivision)) &&
                    c.ContentArticleHOAsubdivisions.Any(cs => cs.SubdivisionsHOA.Any(s => s.TopTierDivisionHOA.Name == topTierDivision)) &&
                    c.Content.ContentType == ContentType.Article &&
                    c.Content.StreamHOA == true &&
                    c.Content.OnHold == false &&
                    DateTimeOffset.UtcNow >= c.Content.StartDate &&
                    DateTimeOffset.UtcNow <= c.Content.EndDate
                    );

链接表格的正确代码是什么,或者我该如何解决?

0 个答案:

没有答案