Files

28 lines
948 B
C#
Raw Permalink Normal View History

2026-08-13 23:10:22 +07:00
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
2026-08-19 23:25:08 +07:00
using mws.backend.dotnet.domain.Tasks;
2026-08-13 23:10:22 +07:00
2026-08-19 23:25:08 +07:00
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
2026-08-13 23:10:22 +07:00
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);
}
}