Backend login and register
This commit is contained in:
25
src/Infrastructure/Configuration/UserRoleConfiguration.cs
Normal file
25
src/Infrastructure/Configuration/UserRoleConfiguration.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Infrastructure.Configuration;
|
||||
|
||||
public class UserRoleConfiguration : IEntityTypeConfiguration<UserRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserRole> 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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user