DocumentConfiguration.cs 1.3 KB

12345678910111213141516171819202122232425262728
  1. using Domain.Entities.Page;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Page;
  5. public sealed class DocumentConfiguration : IEntityTypeConfiguration<Document>
  6. {
  7. public void Configure(EntityTypeBuilder<Document> builder)
  8. {
  9. builder.HasIndex(x => x.Code).IsUnique();
  10. builder.HasIndex(x => x.Subject);
  11. builder.HasIndex(x => x.IsActive);
  12. builder.HasIndex(x => new { x.Code, x.IsActive });
  13. builder.ToTable(nameof(Document), t => t.HasComment("문서"));
  14. builder.HasKey(x => x.ID);
  15. builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
  16. builder.Property(x => x.Code).HasMaxLength(30).IsRequired().HasComment("주소");
  17. builder.Property(x => x.Subject).HasMaxLength(120).IsRequired().HasComment("제목");
  18. builder.Property(x => x.Content).HasMaxLength(5000).HasComment("내용");
  19. builder.Property(x => x.IsActive).IsRequired().HasComment("사용 여부");
  20. builder.Property(x => x.Views).IsRequired().HasComment("조회 수");
  21. builder.Property(x => x.UpdatedAt).HasComment("수정 일시");
  22. builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시");
  23. }
  24. }