mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
31 lines
832 B
C#
31 lines
832 B
C#
using Govor.Core.Models.Users;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Govor.Data.Configurations;
|
|
|
|
public class UserConfiguration : IEntityTypeConfiguration<User>
|
|
{
|
|
public void Configure(EntityTypeBuilder<User> builder)
|
|
{
|
|
builder.HasKey(x => x.Id);
|
|
|
|
builder.HasOne(u => u.Invite)
|
|
.WithMany(i => i.Users)
|
|
.HasForeignKey(u => u.InviteId);
|
|
|
|
builder.Property(u => u.Username)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
builder.HasIndex(u => u.Username).IsUnique();
|
|
|
|
builder.Property(u => u.Description)
|
|
.HasMaxLength(500)
|
|
.IsRequired(false);
|
|
|
|
builder.Property(u => u.PasswordHash)
|
|
.IsRequired()
|
|
.HasMaxLength(128);
|
|
}
|
|
} |