| 1234567891011121314151617181920 |
- using Domain.Entities.Stocks;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- namespace Infrastructure.Persistence.Configurations.Stocks;
- public sealed class StockDailyPriceConfiguration : IEntityTypeConfiguration<StockDailyPrice>
- {
- public void Configure(EntityTypeBuilder<StockDailyPrice> 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("등락률 %");
- }
- }
|