ExchangeRateConfiguration.cs 1.2 KB

12345678910111213141516171819202122
  1. using Domain.Entities.Stocks;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Stocks;
  5. public sealed class ExchangeRateConfiguration : IEntityTypeConfiguration<ExchangeRate>
  6. {
  7. public void Configure(EntityTypeBuilder<ExchangeRate> builder)
  8. {
  9. builder.ToTable(nameof(ExchangeRate), t => t.HasComment("일별 환율 (한국수출입은행 OpenAPI AP01 현재환율)"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasIndex(x => new { x.CurrencyUnit, x.TradeDate }).IsUnique();
  12. builder.HasIndex(x => x.TradeDate);
  13. builder.Property(x => x.CurrencyUnit).HasMaxLength(20).IsRequired().HasComment("통화 코드 (cur_unit) — 예: USD, JPY(100)");
  14. builder.Property(x => x.CurrencyName).HasMaxLength(100).IsRequired().HasComment("통화명 (cur_nm)");
  15. builder.Property(x => x.DealBasRate).HasPrecision(10, 2).HasComment("매매기준율 (deal_bas_r)");
  16. builder.Property(x => x.Ttb).HasPrecision(10, 2).HasComment("전신환 받으실 때 (ttb)");
  17. builder.Property(x => x.Tts).HasPrecision(10, 2).HasComment("전신환 보내실 때 (tts)");
  18. }
  19. }