[Table("ROLES")] public partial class ROLE { public ROLE() { PRIVILIGES = new HashSet<PRIVILIGE>(); USERS = new HashSet<USER>(); } public int ID { get; set; } [Required] [StringLength(20)] public string RoleName { get; set; } [Required] [StringLength(50)] public string Description { get; set; } public virtual ICollection<PRIVILIGE> PRIVILIGES { get; set; } }
[Table("PRIVILIGES")] public partial class PRIVILIGE { public PRIVILIGE() { ROLES = new HashSet<ROLE>(); } public int ID { get; set; } [Required] [StringLength(50)] public string Description { get; set; } public virtual ICollection<ROLE> ROLES { get; set; } }
public partial class TestingContext : DbContext { public TestingContext() : base("name=TestingContext") { } public virtual DbSet<PRIVILIGE> PRIVILIGES { get; set; } public virtual DbSet<ROLE> ROLES { get; set; } public virtual DbSet<USER> USERS { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<PRIVILIGE>() .HasMany(e => e.ROLES) .WithMany(e => e.PRIVILIGES) .Map(m => m.ToTable("RolesPriviliges").MapLeftKey("Perviliges_PreviligeID").MapRightKey("Roles_RolesID")); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)