Files
DotNetAngular/src/Infrastructure/Configuration/UserConfiguration.cs

47 lines
1.5 KiB
C#

using Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Configuration;
public class UserConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
builder.ToTable("Users", "auth");
builder.HasKey(k => k.Id);
builder.Property(x => x.Username)
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)");
builder.Property(x => x.Password)
.IsRequired()
.HasMaxLength(250)
.HasColumnType("varchar(250)");
builder.Property(x => x.Email)
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasAnnotation("RegularExpression", @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
builder.HasMany(x => x.UserRoles)
.WithOne(x => x.User)
.HasForeignKey(x => x.UserId);
builder.HasData(
new User
{
Id = 1, Username = "Superadmin", Email = "superadmin@wenske-services-development.de",
Password = "AQAAAAIAAYagAAAAEADJEu1s5qUJyP4gDUrBGyqSNtKU2IKBpZm0JqfyvOkJnqVeOHZBUrEhNr7IdQRDBQ=="
},
new User
{
Id = 2, Username = "Admin", Email = "admin@wenske-services-development.de",
Password = "AQAAAAIAAYagAAAAEIOUiJUfMrM1Lpt4Ae3FLQOB/Bk6WHtndRAWUp132afVunMvRqkT6Hhh+27kkNW8YQ=="
});
}
}