Ajoute les thèmes communs sur les fiches de livres
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
e28d5bce32
commit
c2d408afc6
@@ -11,6 +11,10 @@ public class MaBibliDbContext(DbContextOptions<MaBibliDbContext> options) : DbCo
|
||||
|
||||
public DbSet<LivreAuteur> LivreAuteurs => Set<LivreAuteur>();
|
||||
|
||||
public DbSet<Theme> Themes => Set<Theme>();
|
||||
|
||||
public DbSet<LivreTheme> LivreThemes => Set<LivreTheme>();
|
||||
|
||||
public DbSet<StatutLecture> StatutsLecture => Set<StatutLecture>();
|
||||
|
||||
public DbSet<RapprochementRefuse> RapprochementsRefuses => Set<RapprochementRefuse>();
|
||||
@@ -94,6 +98,30 @@ public class MaBibliDbContext(DbContextOptions<MaBibliDbContext> options) : DbCo
|
||||
lien.HasIndex(la => la.AuteurId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Theme>(theme =>
|
||||
{
|
||||
theme.Property(t => t.Nom).IsRequired();
|
||||
theme.Property(t => t.NomNormalise).IsRequired();
|
||||
theme.HasIndex(t => t.NomNormalise).IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<LivreTheme>(lien =>
|
||||
{
|
||||
lien.HasKey(lt => new { lt.LivreId, lt.ThemeId });
|
||||
|
||||
lien.HasOne(lt => lt.Livre)
|
||||
.WithMany(l => l.Themes)
|
||||
.HasForeignKey(lt => lt.LivreId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
lien.HasOne(lt => lt.Theme)
|
||||
.WithMany(t => t.Livres)
|
||||
.HasForeignKey(lt => lt.ThemeId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
lien.HasIndex(lt => lt.ThemeId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<StatutLecture>(statut =>
|
||||
{
|
||||
statut.Property(s => s.Utilisateur).IsRequired();
|
||||
|
||||
Reference in New Issue
Block a user