namespace Hutopy.Modules.Creators.Data; public class CreatorsDbContext( DbContextOptions options) : DbContext(options) { public const string SchemaName = "Creators"; public DbSet Creators => Set(); public DbSet Slugs => Set(); protected override void OnModelCreating( ModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema(SchemaName); modelBuilder .Entity() .Property(x => x.NormalizedName) .HasComputedColumnSql("LOWER(\"Name\")", true); modelBuilder .Entity() .HasIndex(x => x.NormalizedName) .IsUnique(); modelBuilder .Entity() .Property(c => c.IsDeleted) .HasComputedColumnSql("\"DeletedAt\" IS NOT NULL", true); // bool modelBuilder .Entity() .OwnsOne(x => x.Socials) .ToTable(nameof(Socials)); modelBuilder .Entity() .OwnsOne(x => x.Presentation) .ToTable(nameof(Presentation)); modelBuilder .Entity() .HasQueryFilter(c => !c.IsDeleted); } }