Clean Architecture Demo
Loading...
Searching...
No Matches
TaskConfiguration.cs
Go to the documentation of this file.
1// TaskManagement.Infrastructure/Persistence/Configurations/TaskConfiguration.cs
2using Microsoft.EntityFrameworkCore;
3using Microsoft.EntityFrameworkCore.Metadata.Builders;
5
7
55public sealed class TaskConfiguration : IEntityTypeConfiguration<TaskRecord>
56{
57 public void Configure(EntityTypeBuilder<TaskRecord> builder)
58 {
59 ArgumentNullException.ThrowIfNull(builder);
60
61 builder.ToTable("Tasks");
62 builder.HasKey(t => t.Id);
63 builder.Property(t => t.Title)
64 .IsRequired()
65 .HasMaxLength(200);
66 builder.Property(t => t.Description)
67 .IsRequired()
68 .HasMaxLength(2000);
69 builder.Property(t => t.Status)
70 .HasConversion<string>()
71 .HasMaxLength(50);
72 builder.Property(t => t.Priority)
73 .HasConversion<string>()
74 .HasMaxLength(50);
75
76 builder.HasIndex(t => t.AssignedTo);
77 builder.HasIndex(t => t.Status);
78 builder.HasIndex(t => t.DueDate);
79 // Filtro de consulta para eliminación suave (si está implementada)
80 // builder.HasQueryFilter(t => !t.IsDeleted);
81 }
82}
var builder
Definition Program.cs:60
TaskConfiguration es la configuración de Entity Framework Core para el objeto del ORM TaskRecord.