using Microsoft.EntityFrameworkCore; using TaskLedger.Api.Domain.Entities; namespace TaskLedger.Api.Infrastructure.Data; /// /// DbContext for the TaskLedger application. /// public class AppDbContext : DbContext { /// /// Initializes a new instance of the class. /// /// The options for this context. public AppDbContext(DbContextOptions options) : base(options) { } /// /// Gets or sets the Tasks DbSet. /// public DbSet Tasks { get; set; } = null!; /// /// Configures the model that was discovered from the entity types exposed in DbSet properties. /// /// The builder being used to construct the model for this context. protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); // Configure Task entity modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.Property(e => e.Title) .IsRequired() .HasMaxLength(200); entity.Property(e => e.Description) .HasMaxLength(1000); entity.Property(e => e.CreatedUtc) .IsRequired(); }); } }