StockWatchConfiguration.cs 1.0 KB

123456789101112131415161718192021
  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 StockWatchConfiguration : IEntityTypeConfiguration<StockWatch>
  6. {
  7. public void Configure(EntityTypeBuilder<StockWatch> builder)
  8. {
  9. builder.ToTable(nameof(StockWatch), x => x.HasComment("회원 관심종목"));
  10. builder.HasKey(x => x.ID);
  11. builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
  12. builder.Property(x => x.MemberID).IsRequired().HasComment("관심 등록 회원 ID");
  13. builder.Property(x => x.StockCode).IsRequired().HasMaxLength(6).IsFixedLength().HasComment("단축코드 (char 6, Stock.Code denorm)");
  14. builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시");
  15. builder.HasIndex(x => new { x.MemberID, x.StockCode }).IsUnique();
  16. builder.HasIndex(x => new { x.MemberID, x.CreatedAt }).IsDescending(false, true);
  17. }
  18. }