"The entity type XXModel is not part of the model for the current context."

川长思鸟来 2021-07-26 19:12 674阅读 0赞

碰见这个错误是由于在Entity Framework中访问数据中不存在的实体模型:

解决方法配置映射关系:

  1. public class CompanyMap : EntityTypeConfiguration<CompanyEntity>
  2. {
  3. public CompanyMap()
  4. {
  5. #region 表、主键
  6. //表
  7. this.ToTable("LR_BASE_COMPANY");
  8. //主键
  9. this.HasKey(t => t.F_CompanyId);
  10. #endregion
  11. #region 配置关系
  12. #endregion
  13. }
  14. }

发表评论

表情:
评论列表 (有 0 条评论,674人围观)

还没有评论,来说两句吧...

相关阅读