using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class StockDailyPriceConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasOne(x => x.Stock).WithMany().HasForeignKey(x => x.StockID).OnDelete(DeleteBehavior.NoAction); builder.HasIndex(x => new { x.StockID, x.TradingDate }).IsUnique(); builder.HasIndex(x => new { x.TradingDate, x.ChangeRate }).IsDescending(false, true); builder.HasIndex(x => new { x.TradingDate, x.TradingValue }).IsDescending(false, true); builder.ToTable(nameof(StockDailyPrice), t => t.HasComment("T+1 일별 마감 시세 (금융위 API)")); builder.HasKey(x => x.ID); builder.Property(x => x.ChangeRate).HasPrecision(7, 2).HasComment("등락률 %"); } }