"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
        }
    }

 

posted @ 2019-10-31 16:43  星空天宇  阅读(663)  评论(0编辑  收藏  举报