Files
mws.backend.dotnet/mws.infrastructure/Persistence/Configuration/TaskConfiguration.cs
T

28 lines
918 B
C#
Raw Normal View History

2026-08-13 23:10:22 +07:00
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Mws.Domain.Tasks;
namespace Mws.Infrastructure.Persistence.Configuration;
public class TaskConfiguration : IEntityTypeConfiguration<TaskItem>
{
public void Configure(EntityTypeBuilder<TaskItem> e)
{
e.ToTable("tasks");
e.HasKey(t => t.Id);
e.Property(t => t.Title).HasMaxLength(300).IsRequired();
e.Property(t => t.Description).HasColumnType("text");
e.Property(t => t.Status).HasConversion<string>().HasMaxLength(20);
e.Property(t => t.Priority).HasConversion<string>().HasMaxLength(20);
e.HasIndex(t => t.ProjectId);
e.HasIndex(t => t.AssigneeId);
e.HasIndex(t => t.Status);
e.HasOne(t => t.Assignee)
.WithMany()
.HasForeignKey(t => t.AssigneeId)
.OnDelete(DeleteBehavior.SetNull);
}
}