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);
  • 相关阅读:
    Modelsim中观测代码覆盖率
    Allegro中Thermal relief Pad 和Anti Pad
    时序逻辑中阻塞赋值引起的仿真问题
    如何提高FPGA工作频率(转载)
    `include在Verilog中的应用
    forever
    wxpython 应用 使用 google gauth 认证
    sql to sqlalchemy 转换
    django 简易博客开发 5 markdown支持、代码高亮、gravatar头像服务
    simpletodo: 一个简易的 todo 程序 django版
  • 原文地址:https://www.cnblogs.com/honghong75042/p/4578803.html
Copyright © 2011-2022 走看看