Files
IM_NEW/GroupService.Infrastructure/Configs/GroupJoinRequestConfig.cs

41 lines
1.3 KiB
C#

using GroupService.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace GroupService.Infrastructure.Configs
{
public class GroupJoinRequestConfig : IEntityTypeConfiguration<GroupJoinRequest>
{
public void Configure(EntityTypeBuilder<GroupJoinRequest> builder)
{
builder.ToTable("group_join_requests");
builder.HasKey(x => x.Id);
builder.HasKey(x => new { x.GroupId, x.UserId });
builder.HasIndex(x => x.Id).IsUnique();
builder.HasIndex(x => new { x.GroupId, x.State, x.CreationTime });
builder.HasIndex(x => new { x.UserId, x.CreationTime });
builder.ComplexProperty(x => x.UserProfile, u =>
{
u.Property(p => p.Avatar)
.HasMaxLength(100);
u.Property(p => p.NickName)
.IsRequired()
.HasMaxLength(20);
});
builder.ComplexProperty(x => x.GroupProfile, u =>
{
u.Property(p => p.Avatar)
.IsRequired()
.HasMaxLength(100);
u.Property(p => p.GroupName)
.IsRequired()
.HasMaxLength(20);
});
}
}
}