ApiApplicationConfiguration.cs 1.1 KB

123456789101112131415161718192021222324
  1. using Domain.Entities.Developers;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Developers;
  5. public class ApiApplicationConfiguration : IEntityTypeConfiguration<ApiApplication>
  6. {
  7. public void Configure(EntityTypeBuilder<ApiApplication> builder)
  8. {
  9. builder.HasOne(x => x.Owner).WithMany().HasForeignKey(x => x.OwnerMemberID).OnDelete(DeleteBehavior.Cascade);
  10. builder.HasIndex(x => x.OwnerMemberID);
  11. builder.HasIndex(x => x.Status);
  12. builder.ToTable(nameof(ApiApplication), x => x.HasComment("개발자 API 앱"));
  13. builder.HasKey(x => x.ID);
  14. builder.Property(x => x.Name).HasMaxLength(100).IsRequired();
  15. builder.Property(x => x.Description).HasMaxLength(500);
  16. builder.Property(x => x.HomepageUrl).HasMaxLength(500);
  17. builder.Property(x => x.LogoPath).HasMaxLength(500);
  18. builder.Property(x => x.Status).HasConversion<int>().IsRequired();
  19. builder.Property(x => x.CreatedAt).IsRequired();
  20. }
  21. }