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);

 

你可能感兴趣的:(查询)