feat(album): add cover picture functionality to albums and enhance album management API

This commit is contained in:
shiyu
2025-06-09 15:12:50 +08:00
parent 9d9393f9ce
commit e55f311c04
24 changed files with 1496 additions and 251 deletions

View File

@@ -15,4 +15,20 @@ public class MyDbContext(DbContextOptions<MyDbContext> options) : DbContext(opti
public DbSet<Log> Logs { get; set; } = null!;
public DbSet<BackgroundTask> BackgroundTasks { get; set; } = null!;
public DbSet<StorageMode> StorageModes { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Album>()
.HasOne(a => a.CoverPicture)
.WithMany()
.HasForeignKey(a => a.CoverPictureId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<Album>()
.HasMany(a => a.Pictures)
.WithOne(p => p.Album)
.HasForeignKey(p => p.AlbumId)
.OnDelete(DeleteBehavior.Cascade);
}
}