From 556260df84627efbbe24f70185e53089f1b90e7c Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sun, 19 Mar 2023 15:36:42 +0100
Subject: [PATCH] Debut Many to Many entre Champion et Runes :package:
---
Sources/EntityFramework/ChampionEntity.cs | 5 +++++
Sources/EntityFramework/LoLDbContext.cs | 26 ++++++++++++++++++++---
Sources/EntityFramework/RunePageEntity.cs | 4 +++-
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index d672964..02e5a2d 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -34,6 +34,11 @@ namespace EntityFramework
private ICollection Skills { get; set; }
+ // Pour le many to many Champion *<---->* RunePage
+ public ICollection RunePageEntities{ get; set; }
+
+
+
public ChampionEntity(string name,string bio,string icon) {
this.Name = name;
this.Bio = bio;
diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs
index 2c4c22b..354aa89 100644
--- a/Sources/EntityFramework/LoLDbContext.cs
+++ b/Sources/EntityFramework/LoLDbContext.cs
@@ -11,7 +11,7 @@ namespace EntityFramework
{
public DbSet Champions { get; set; }
- public DbSet Rune { get; set; }
+ public DbSet Rune { get; set; }
public DbSet RunePage { get; set; }
@@ -38,7 +38,7 @@ namespace EntityFramework
//modelBuilder.Entity().Property(entity => entity.Id)
// .ValueGeneratedOnAdd();
-
+
modelBuilder.Entity().Property(entity => entity.Name)
.IsRequired()
.HasMaxLength(50);
@@ -50,7 +50,27 @@ namespace EntityFramework
modelBuilder.Entity().Property(entity => entity.Icon)
.IsRequired();
-
+
+
+
+
+
+
+ // Many to Many ChampionEntity - RunePageEntity
+ modelBuilder.Entity().HasKey(entity => entity.Name);
+ modelBuilder.Entity().ToTable("RunePage");
+
+
+ // Use the shadow property as a foreign key
+ modelBuilder.Entity()
+ .HasMany(r => r.Champion)
+ .WithMany(c => c.RunePageEntities);
+ //.HasForeignKey("AlbumForeignKey");
+
+ modelBuilder.Entity()
+ .HasMany(c => c.RunePageEntities)
+ .WithMany(r => r.Champion);
+ //.HasForeignKey("AlbumForeignKey");
}
}
}
diff --git a/Sources/EntityFramework/RunePageEntity.cs b/Sources/EntityFramework/RunePageEntity.cs
index e274bbf..7e4e1ce 100644
--- a/Sources/EntityFramework/RunePageEntity.cs
+++ b/Sources/EntityFramework/RunePageEntity.cs
@@ -16,8 +16,10 @@ namespace EntityFramework
public Rune? Rune { get; set; }
//? voir si cela pause probleme
- Dictionary Dico = new Dictionary();
+ public Dictionary Dico = new Dictionary();
+ // Pour le many to many Champion *<---->* RunePage
+ public ICollection Champion{ get; set; }