using Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Configuration; public class UserRoleConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("UserRoles", "auth"); builder.HasKey(x => new { x.UserId, x.RoleId }); builder.HasOne(x => x.User) .WithMany(x => x.UserRoles) .HasForeignKey(x => x.UserId); builder.HasOne(x => x.Role) .WithMany(x => x.UserRoles) .HasForeignKey(x => x.RoleId); builder.HasData( new UserRole { UserId = 1, RoleId = 1 }, new UserRole { UserId = 2, RoleId = 2 }); } }