using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using WatchIt.Database.Converters; using WatchIt.Database.Model.Photos; namespace WatchIt.Database.Configuration.Photos; public class PhotoBackgroundConfiguration : IEntityTypeConfiguration { #region PUBLIC METHODS public void Configure(EntityTypeBuilder builder) { builder.ToTable("PhotoBackground", "photos"); // Id builder.HasKey(x => x.Id); builder.HasIndex(x => x.Id) .IsUnique(); builder.Property(x => x.Id) .IsRequired(); // Photo builder.HasOne(x => x.Photo) .WithOne(x => x.Background) .HasForeignKey(x => x.PhotoId) .IsRequired(); builder.HasIndex(x => x.PhotoId) .IsUnique(); builder.Property(x => x.PhotoId) .IsRequired(); // Is universal builder.Property(x => x.IsUniversal) .IsRequired() .HasDefaultValue(false); // First gradient color builder.Property(x => x.FirstGradientColor) .HasConversion() .IsRequired(); // Second gradient color builder.Property(x => x.SecondGradientColor) .HasConversion() .IsRequired(); // Version builder.Property(b => b.Version) .IsRowVersion(); } #endregion }