$mermaidjs
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<TaskItem>
56{
57 public void Configure(EntityTypeBuilder<TaskItem> 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 // Los eventos del dominio están solo en memoria y no deben ser persistidos por EF.
77 builder.Ignore(t => t.DomainEvents);
78
79 builder.HasIndex(t => t.AssignedTo);
80 builder.HasIndex(t => t.Status);
81 builder.HasIndex(t => t.DueDate);
82 // Filtro de consulta para eliminación suave (si está implementada)
83 // builder.HasQueryFilter(t => !t.IsDeleted);
84 }
85}
var builder
Definition Program.cs:55
TaskConfiguration es la configuración de Entity Framework Core para entidad TaskItem.