zoukankan      html  css  js  c++  java
  • NopCommerce4.2 常见错误及异常处理

    An error occurred while starting the application.

    InvalidOperationException: No field was found backing property 'WeiActivityWinInfos' of entity type 'WeiActivityInfo'. Lazy-loaded navigation properties must have backing fields. Either name the backing field so that it is picked up by convention or configure the backing field to use.

    Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.ValidateFieldMapping(IModel model)

    InvalidOperationException: No field was found backing property 'WeiActivityWinInfos' of entity type 'WeiActivityInfo'. Lazy-loaded navigation properties must have backing fields. Either name the backing field so that it is picked up by convention or configure the backing field to use.

    出现以上问题,主要是导航属性命名不规范导致的

    错误代码

      public partial class WeiActivityInfo : BaseEntity
        {

            private ICollection<WeiActivityWinInfo> _weiActivityWinInfo;
       
            public virtual ICollection<WeiActivityWinInfo> WeiActivityWinInfos
            {
                get { return _weiActivityWinInfo?? (_weiActivityWinInfo= new List<WeiActivityWinInfo>()); }
                protected set { _weiActivityWinInfo= value; }
            }
        }

     EF 导航配置命名上要保持一致,否则可能到这个错误,正确的配置,保证

    private与public 属性集合名称一致!

    public partial class WeiActivityInfo : BaseEntity
        {

            private ICollection<WeiActivityWinInfo> _weiActivityWinInfos;
       
            public virtual ICollection<WeiActivityWinInfo> WeiActivityWinInfos
            {
                get { return _weiActivityWinInfos?? (_weiActivityWinInfos= new List<WeiActivityWinInfo>()); }
                protected set { _weiActivityWinInfos= value; }
            }
        }

  • 相关阅读:
    next_permutation函数(全排列)
    滚动数组
    多重背包问题
    ubuntu12.04硬盘安装
    UBUNTU12.04下安装配置体验gnome3
    给Ubuntu安装KDE桌面 [转]
    Ubuntu 13.04 用户安装 gnome 3.8 桌面
    ubuntu下安装wine
    ubuntu 安装输入法(fcitx)
    js 对url进行编码和解码的三种方式
  • 原文地址:https://www.cnblogs.com/chenyuxi/p/11924760.html
Copyright © 2011-2022 走看看