SHARE
TWEET

Untitled

a guest Jul 12th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.         protected override void OnModelCreating(ModelBuilder modelBuilder)
  3.         {
  4.             base.OnModelCreating(modelBuilder);
  5.  
  6.             modelBuilder.Entity<UserRoleModel>()
  7.                 .HasKey(ur => new { ur.UserId, ur.RoleId });
  8.             modelBuilder.Entity<UserRoleModel>()
  9.                 .HasOne(ur => ur.User)
  10.                 .WithMany(u => u.UserRoles)
  11.                 .HasForeignKey(ur => ur.UserId);
  12.             modelBuilder.Entity<UserRoleModel>()
  13.                 .HasOne(ur => ur.Role)
  14.                 .WithMany(r => r.UserRoles)
  15.                 .HasForeignKey(ur => ur.RoleId);
  16.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top