ioc+ef+core搭建模型映射(三)

/// <summary>
    /// 表示类别映射配置
    /// </summary>
    public partial class sys_UserMap : NopEntityTypeConfiguration<sys_User>
    {
        public override void Configure(EntityTypeBuilder<sys_User> builder)
        {
            builder.ToTable(nameof(sys_User));
            builder.HasKey(sysUser => sysUser.gid);

            builder.Property(sysUser => sysUser.userLoginName).HasMaxLength(30).IsRequired();
            builder.Property(sysUser => sysUser.userPwd).HasMaxLength(30).IsRequired();
            builder.Property(sysUser => sysUser.userEmail).HasMaxLength(50);

            //builder.Ignore(category => category.AppliedDiscounts);

            base.Configure(builder);
        }
    }

模型必须映射,不然会报找不到模型错误,在NopObjectContext的OnModelCreating会自动加入模型,

demo地址:https://pan.baidu.com/s/1F6MsZs5T8JZbHom_mvIRUA     fiyl

需要自己配置数据库,以及泛型集合,

上一篇:MongoTemplate进行增删改查


下一篇:【乱七八糟的笔记】——前缀树