Added but did not complete the repository for cover art, updated migration script to create migration for CoverArt, and prepping for the cover art api

This commit is contained in:
amazing-username
2019-07-07 15:02:38 -04:00
parent 82686f5c33
commit 0932be2f2b
7 changed files with 142 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using MySql.Data;
using MySql.Data.EntityFrameworkCore.Extensions;
using MySql.Data.MySqlClient;
using Icarus.Models;
namespace Icarus.Database.Contexts
{
public class CoverArtContext : DbContext
{
public DbSet<CoverArt> CoverArtImages { get; set; }
public CoverArtContext(DbContextOptions<CoverArtContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<CoverArt>()
.ToTable("CoverArt");
}
}
}
+9
View File
@@ -46,6 +46,12 @@ namespace Icarus.Database.Contexts
.HasForeignKey(s => s.YearId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<Song>()
.HasOne(s => s.SongCoverArt)
.WithMany(ca => ca.Songs)
.HasForeignKey(s => s.CoverArtId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<Song>()
.Property(s => s.Year)
.IsRequired(false);
@@ -61,6 +67,9 @@ namespace Icarus.Database.Contexts
modelBuilder.Entity<Song>()
.Property(s => s.AlbumId)
.IsRequired(false);
modelBuilder.Entity<Song>()
.Property(s => s.CoverArtId)
.IsRequired(false);
}
}
}