This commit is contained in:
kdeng00
2021-12-22 21:33:12 -05:00
parent 922e527819
commit 8600d9b6bc
31 changed files with 495 additions and 1000 deletions
+16 -6
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using MySql.Data;
@@ -14,12 +15,21 @@ namespace Icarus.Database.Contexts
{
public DbSet<Album> Albums { get; set; }
public AlbumContext(DbContextOptions<AlbumContext> options) : base(options) { }
public AlbumContext(DbContextOptions<AlbumContext> options) : base(options) { }
public AlbumContext(string connString) : base(new DbContextOptionsBuilder<AlbumContext>()
.UseMySQL(connString).Options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Album>()
.ToTable("Album");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Album>()
.ToTable("Album");
}
public bool DoesRecordExist(Album album)
{
return Albums.FirstOrDefault(alb => alb.AlbumId == album.AlbumId) != null ? true : false;
}
}
}