"The entity type XXModel is not part of the model for the current context."
碰见这个错误是由于在Entity Framework中访问数据中不存在的实体模型:
解决方法配置映射关系:
public class CompanyMap : EntityTypeConfiguration<CompanyEntity>
{
public CompanyMap()
{
#region 表、主键
//表
this.ToTable("LR_BASE_COMPANY");
//主键
this.HasKey(t => t.F_CompanyId);
#endregion
#region 配置关系
#endregion
}
}