mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
Create disk entity for database.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user