zoukankan      html  css  js  c++  java
  • EF有外键的查询

                modelBuilder.Entity<ActionMenu>().ToTable("ActionMenu");
                modelBuilder.Entity<ActionMenu>().HasKey(s => s.Id);
                modelBuilder.Entity<ActionMenu>().Property(s => s.MenuName).IsRequired().HasMaxLength(50);
    
    
                modelBuilder.Entity<ActionMenu>().HasMany(t => t.ChildActions)
                    .WithMany()
                    .Map(m =>
                    {
                        m.ToTable("ActionMenu_ActionInfo_Mapping");
                        m.MapLeftKey("ActionMenuId");
                        m.MapRightKey("ActionInfoId");
                    });
    
                modelBuilder.Entity<ActionMenu>().HasOptional(p => p.Parent).WithMany(p => p.ChildKeys);
    
    
                modelBuilder.Entity<ErpMember>().ToTable("ErpMember");
                modelBuilder.Entity<ErpMember>().HasKey(s => s.Id);
                modelBuilder.Entity<ErpMember>().Property(s => s.Email).IsRequired().HasMaxLength(50);
                modelBuilder.Entity<ErpMember>().Property(s => s.Moblie).IsRequired().HasMaxLength(20);
                modelBuilder.Entity<ErpMember>().Property(s => s.PassWord).IsRequired().HasMaxLength(50);
                modelBuilder.Entity<ErpMember>().Property(s => s.UserName).IsRequired().HasMaxLength(50);
                modelBuilder.Entity<ErpMember>().Property(s => s.LastIpAddress).HasMaxLength(20);
    
                //modelBuilder.Entity<ErpMember>().HasMany(b => b.ChildKeys).WithRequired(p => p.Parent);
                modelBuilder.Entity<ErpMember>().HasOptional(p => p.Parent).WithMany(p => p.ChildKeys);
    
                modelBuilder.Entity<BillLoanApply>().ToTable("BillLoanApply");
                modelBuilder.Entity<BillLoanApplyDetail>().ToTable("BillLoanApplyDetail");
                modelBuilder.Entity<BillRepayment>().ToTable("BillRepayment");
                modelBuilder.Entity<DictEnum>().ToTable("DictEnum");
                modelBuilder.Entity<MapSignInTask>().ToTable("MapSignInTask");
    
    
                // BillLoanApply 贷款申请表
                modelBuilder.Entity<BillLoanApply>().ToTable("BillLoanApply");
                modelBuilder.Entity<BillLoanApply>().HasKey(b => b.Id);
  • 相关阅读:
    thymeleaf常用属性
    spring的jdbcTemplate的使用
    spring使用thymeleaf
    thymeleaf介绍
    struts2请求过程源码分析
    Git 学习笔记之(三)将本地工程导入到GitHub 仓库中
    spring boot 学习笔记(三)之 配置
    Zookeeper 学习笔记(一)之功能介绍
    Git 学习笔记之(一) 使用 git gui 从github上下载代码
    Linux 清理空间
  • 原文地址:https://www.cnblogs.com/honghong75042/p/4578803.html
Copyright © 2011-2022 走看看