小编kar*_*thi的帖子

实体框架代码优先 - 无效的列名称Discriminator

codefirst中的两个类

public partial class BaseEntity 
{
    public int ID { get; set; }
}

public partial class Fund : BaseEntity
{
   public int Name { get; set; }
}
public partial class InvestorFund : BaseEntity 
{
  public int FundID { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

映射类

this.Property(t => t.ID).HasColumnName("FundID");
Run Code Online (Sandbox Code Playgroud)

我的代码首先加入SQL查询

from fund in context.Funds

join investorFund in context.InvestorFunds on fund.ID equals investorFund.FundID
Run Code Online (Sandbox Code Playgroud)

抛出一个 Invalid column name Discriminator

ef-code-first

3
推荐指数
1
解决办法
5720
查看次数

标签 统计

ef-code-first ×1