Create disk entity for database.

This commit is contained in:
2020-09-04 02:12:38 +01:00
parent 1caca29060
commit fc675fd764
7 changed files with 535 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ namespace RomRepoMgr.Database
public DbSet<RomSet> RomSets { get; set; }
public DbSet<Machine> Machines { get; set; }
public DbSet<FileByMachine> FilesByMachines { get; set; }
public DbSet<DbDisk> Disks { get; set; }
public DbSet<DiskByMachine> DisksByMachines { get; set; }
public static void ReplaceSingleton(string dbPath) => _singleton = Create(dbPath);
@@ -129,6 +131,24 @@ namespace RomRepoMgr.Database
entity.HasOne(e => e.File).WithMany(e => e.Machines).OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<DbDisk>(entity =>
{
entity.HasIndex(e => e.Md5);
entity.HasIndex(e => e.Sha1);
entity.HasIndex(e => e.Size);
});
modelBuilder.Entity<DiskByMachine>(entity =>
{
entity.HasIndex(e => e.Name);
entity.HasOne(e => e.Machine).WithMany(e => e.Disks).OnDelete(DeleteBehavior.Cascade);
entity.HasOne(e => e.Disk).WithMany(e => e.Machines).OnDelete(DeleteBehavior.Cascade);
});
}
}
}