From 14ddb60602538368cb62029bcfc4bfa4a8716db0 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Thu, 23 Mar 2023 21:37:02 +0100
Subject: [PATCH] ManyMany Champions -> RUnePage Working :white_check_mark: !
---
Sources/EntityFramework/LoLDbContext.cs | 1 +
...=> 20230323203441_manymanymig.Designer.cs} | 108 +++++++++++-------
...myMig.cs => 20230323203441_manymanymig.cs} | 82 ++++++++++---
...apshot.cs => LoLDbContextModelSnapshot.cs} | 106 ++++++++++-------
Sources/EntityFramework/Program.cs | 19 ++-
Sources/EntityFramework/RunePageEntity.cs | 4 +-
Sources/EntityFramework/champion.db | Bin 53248 -> 86016 bytes
7 files changed, 221 insertions(+), 99 deletions(-)
rename Sources/EntityFramework/Migrations/{20230315145258_myMig.Designer.cs => 20230323203441_manymanymig.Designer.cs} (65%)
rename Sources/EntityFramework/Migrations/{20230315145258_myMig.cs => 20230323203441_manymanymig.cs} (58%)
rename Sources/EntityFramework/Migrations/{LoLDBContextWithStubModelSnapshot.cs => LoLDbContextModelSnapshot.cs} (64%)
diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs
index 57d65a8..6812e57 100644
--- a/Sources/EntityFramework/LoLDbContext.cs
+++ b/Sources/EntityFramework/LoLDbContext.cs
@@ -80,6 +80,7 @@ namespace EntityFramework
// Many to Many ChampionEntity - RunePageEntity
+ modelBuilder.Entity().HasKey(entity => entity.Name);
modelBuilder.Entity().HasKey(entity => entity.Name);
modelBuilder.Entity().ToTable("RunePage");
diff --git a/Sources/EntityFramework/Migrations/20230315145258_myMig.Designer.cs b/Sources/EntityFramework/Migrations/20230323203441_manymanymig.Designer.cs
similarity index 65%
rename from Sources/EntityFramework/Migrations/20230315145258_myMig.Designer.cs
rename to Sources/EntityFramework/Migrations/20230323203441_manymanymig.Designer.cs
index 34ce7d8..f36cc78 100644
--- a/Sources/EntityFramework/Migrations/20230315145258_myMig.Designer.cs
+++ b/Sources/EntityFramework/Migrations/20230323203441_manymanymig.Designer.cs
@@ -9,9 +9,9 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFramework.Migrations
{
- [DbContext(typeof(LoLDBContextWithStub))]
- [Migration("20230315145258_myMig")]
- partial class myMig
+ [DbContext(typeof(LoLDbContext))]
+ [Migration("20230323203441_manymanymig")]
+ partial class manymanymig
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -19,6 +19,21 @@ namespace EntityFramework.Migrations
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
+ modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
+ {
+ b.Property("ChampionName")
+ .HasColumnType("TEXT");
+
+ b.Property("RunePageEntitiesName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ChampionName", "RunePageEntitiesName");
+
+ b.HasIndex("RunePageEntitiesName");
+
+ b.ToTable("ChampionEntityRunePageEntity");
+ });
+
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Property("Name")
@@ -41,44 +56,6 @@ namespace EntityFramework.Migrations
b.HasKey("Name");
b.ToTable("Champion", (string)null);
-
- b.HasData(
- new
- {
- Name = "Akali",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Aatrox",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Ahri",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Akshan",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Bard",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Alistar",
- Bio = "",
- Icon = ""
- });
});
modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
@@ -96,6 +73,31 @@ namespace EntityFramework.Migrations
b.ToTable("Image");
});
+ modelBuilder.Entity("EntityFramework.RuneEntity", b =>
+ {
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Rune");
+ });
+
+ modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
+ {
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("RuneName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.HasIndex("RuneName");
+
+ b.ToTable("RunePage", (string)null);
+ });
+
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.Property("Name")
@@ -147,6 +149,30 @@ namespace EntityFramework.Migrations
b.ToTable("Skins");
});
+ modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
+ {
+ b.HasOne("EntityFramework.ChampionEntity", null)
+ .WithMany()
+ .HasForeignKey("ChampionName")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("EntityFramework.RunePageEntity", null)
+ .WithMany()
+ .HasForeignKey("RunePageEntitiesName")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
+ {
+ b.HasOne("EntityFramework.RuneEntity", "Rune")
+ .WithMany()
+ .HasForeignKey("RuneName");
+
+ b.Navigation("Rune");
+ });
+
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.HasOne("EntityFramework.ChampionEntity", null)
diff --git a/Sources/EntityFramework/Migrations/20230315145258_myMig.cs b/Sources/EntityFramework/Migrations/20230323203441_manymanymig.cs
similarity index 58%
rename from Sources/EntityFramework/Migrations/20230315145258_myMig.cs
rename to Sources/EntityFramework/Migrations/20230323203441_manymanymig.cs
index 86b3a87..3908652 100644
--- a/Sources/EntityFramework/Migrations/20230315145258_myMig.cs
+++ b/Sources/EntityFramework/Migrations/20230323203441_manymanymig.cs
@@ -2,12 +2,10 @@
#nullable disable
-#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
-
namespace EntityFramework.Migrations
{
///
- public partial class myMig : Migration
+ public partial class manymanymig : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
@@ -39,6 +37,17 @@ namespace EntityFramework.Migrations
table.PrimaryKey("PK_Image", x => x.Id);
});
+ migrationBuilder.CreateTable(
+ name: "Rune",
+ columns: table => new
+ {
+ Name = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Rune", x => x.Name);
+ });
+
migrationBuilder.CreateTable(
name: "SkillEntity",
columns: table => new
@@ -79,19 +88,57 @@ namespace EntityFramework.Migrations
principalColumn: "Name");
});
- migrationBuilder.InsertData(
- table: "Champion",
- columns: new[] { "Name", "Bio", "Icon", "Image" },
- values: new object[,]
+ migrationBuilder.CreateTable(
+ name: "RunePage",
+ columns: table => new
+ {
+ Name = table.Column(type: "TEXT", nullable: false),
+ RuneName = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_RunePage", x => x.Name);
+ table.ForeignKey(
+ name: "FK_RunePage_Rune_RuneName",
+ column: x => x.RuneName,
+ principalTable: "Rune",
+ principalColumn: "Name");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ChampionEntityRunePageEntity",
+ columns: table => new
+ {
+ ChampionName = table.Column(type: "TEXT", nullable: false),
+ RunePageEntitiesName = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
{
- { "Aatrox", "", "", null },
- { "Ahri", "", "", null },
- { "Akali", "", "", null },
- { "Akshan", "", "", null },
- { "Alistar", "", "", null },
- { "Bard", "", "", null }
+ table.PrimaryKey("PK_ChampionEntityRunePageEntity", x => new { x.ChampionName, x.RunePageEntitiesName });
+ table.ForeignKey(
+ name: "FK_ChampionEntityRunePageEntity_Champion_ChampionName",
+ column: x => x.ChampionName,
+ principalTable: "Champion",
+ principalColumn: "Name",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_ChampionEntityRunePageEntity_RunePage_RunePageEntitiesName",
+ column: x => x.RunePageEntitiesName,
+ principalTable: "RunePage",
+ principalColumn: "Name",
+ onDelete: ReferentialAction.Cascade);
});
+ migrationBuilder.CreateIndex(
+ name: "IX_ChampionEntityRunePageEntity_RunePageEntitiesName",
+ table: "ChampionEntityRunePageEntity",
+ column: "RunePageEntitiesName");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RunePage_RuneName",
+ table: "RunePage",
+ column: "RuneName");
+
migrationBuilder.CreateIndex(
name: "IX_SkillEntity_ChampionEntityName",
table: "SkillEntity",
@@ -106,6 +153,9 @@ namespace EntityFramework.Migrations
///
protected override void Down(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.DropTable(
+ name: "ChampionEntityRunePageEntity");
+
migrationBuilder.DropTable(
name: "Image");
@@ -115,8 +165,14 @@ namespace EntityFramework.Migrations
migrationBuilder.DropTable(
name: "Skins");
+ migrationBuilder.DropTable(
+ name: "RunePage");
+
migrationBuilder.DropTable(
name: "Champion");
+
+ migrationBuilder.DropTable(
+ name: "Rune");
}
}
}
diff --git a/Sources/EntityFramework/Migrations/LoLDBContextWithStubModelSnapshot.cs b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
similarity index 64%
rename from Sources/EntityFramework/Migrations/LoLDBContextWithStubModelSnapshot.cs
rename to Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
index 1bbd357..e65f6fe 100644
--- a/Sources/EntityFramework/Migrations/LoLDBContextWithStubModelSnapshot.cs
+++ b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
@@ -8,14 +8,29 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace EntityFramework.Migrations
{
- [DbContext(typeof(LoLDBContextWithStub))]
- partial class LoLDBContextWithStubModelSnapshot : ModelSnapshot
+ [DbContext(typeof(LoLDbContext))]
+ partial class LoLDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
+ modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
+ {
+ b.Property("ChampionName")
+ .HasColumnType("TEXT");
+
+ b.Property("RunePageEntitiesName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ChampionName", "RunePageEntitiesName");
+
+ b.HasIndex("RunePageEntitiesName");
+
+ b.ToTable("ChampionEntityRunePageEntity");
+ });
+
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Property("Name")
@@ -38,44 +53,6 @@ namespace EntityFramework.Migrations
b.HasKey("Name");
b.ToTable("Champion", (string)null);
-
- b.HasData(
- new
- {
- Name = "Akali",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Aatrox",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Ahri",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Akshan",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Bard",
- Bio = "",
- Icon = ""
- },
- new
- {
- Name = "Alistar",
- Bio = "",
- Icon = ""
- });
});
modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
@@ -93,6 +70,31 @@ namespace EntityFramework.Migrations
b.ToTable("Image");
});
+ modelBuilder.Entity("EntityFramework.RuneEntity", b =>
+ {
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Rune");
+ });
+
+ modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
+ {
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("RuneName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.HasIndex("RuneName");
+
+ b.ToTable("RunePage", (string)null);
+ });
+
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.Property("Name")
@@ -144,6 +146,30 @@ namespace EntityFramework.Migrations
b.ToTable("Skins");
});
+ modelBuilder.Entity("ChampionEntityRunePageEntity", b =>
+ {
+ b.HasOne("EntityFramework.ChampionEntity", null)
+ .WithMany()
+ .HasForeignKey("ChampionName")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("EntityFramework.RunePageEntity", null)
+ .WithMany()
+ .HasForeignKey("RunePageEntitiesName")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
+ {
+ b.HasOne("EntityFramework.RuneEntity", "Rune")
+ .WithMany()
+ .HasForeignKey("RuneName");
+
+ b.Navigation("Rune");
+ });
+
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.HasOne("EntityFramework.ChampionEntity", null)
diff --git a/Sources/EntityFramework/Program.cs b/Sources/EntityFramework/Program.cs
index 818faa5..dfe3c7e 100644
--- a/Sources/EntityFramework/Program.cs
+++ b/Sources/EntityFramework/Program.cs
@@ -1,6 +1,8 @@
// See https://aka.ms/new-console-template for more information
using EntityFramework;
using Microsoft.EntityFrameworkCore;
+using Model;
+using System.Buffers.Text;
using ( var context = new LoLDbContext())
{
@@ -24,10 +26,10 @@ using ( var context = new LoLDbContext())
ChampionEntity champSkill = new ChampionEntity { Name="nomSkill", Bio="bioSkill", Icon="iconSkill" };
//SkillEntity s1 = new SkillEntity { Name = "Skill1", Description = "desc", Type = SkillType.Unknown };
- SkillEntity s2 = new SkillEntity { Name="Skill2", Description="desc2", Type=SkillType.Ultimate };
- SkillEntity s3 = new SkillEntity { Name = "Skill3", Description = "desc3", Type = SkillType.Passive };
+ SkillEntity s2 = new SkillEntity { Name="Skill2", Description="desc2", Type= EntityFramework.SkillType.Ultimate };
+ SkillEntity s3 = new SkillEntity { Name = "Skill3", Description = "desc3", Type = EntityFramework.SkillType.Passive };
- champSkill.AddSkill(new SkillEntity { Name = "Skill1", Description = "desc", Type = SkillType.Unknown });
+ champSkill.AddSkill(new SkillEntity { Name = "Skill1", Description = "desc", Type = EntityFramework.SkillType.Unknown });
champSkill.AddSkill(s2);
champSkill.AddSkill(s3);
@@ -75,4 +77,15 @@ using ( var context = new LoLDbContext())
context.SaveChanges();
+ var r1 = new RuneEntity { Name = "Rune1", Description = "aaa", Family = EnumRuneFamily.Domination, Image = new LargeImage("base") };
+ var r2 = new RuneEntity { Name = "Rune2", Description = "aaa", Family = EnumRuneFamily.Domination, Image = new LargeImage("base") };
+ var corichard = new ChampionEntity { Name = "Corichard", Bio = "biobio", Icon = "Icon.png" };
+ var pintrand = new ChampionEntity { Name = "Pintrand", Bio = "biobio", Icon = "Icon.png" };
+ var rp1 = new RunePageEntity { Name = "RP1", Rune = new RuneEntity { Name = "aa", Description = "aaa", Family = EnumRuneFamily.Domination, Image = new LargeImage("base") }, Champion = new List { corichard } };
+ var rp2 = new RunePageEntity { Name = "RP2", Rune = new RuneEntity{ Name = "aaa", Description = "aaa", Family = EnumRuneFamily.Domination, Image = new LargeImage("base") }, Champion = new List { pintrand } };
+
+ context.Rune.AddRange(new[] { r1, r2 });
+ context.Champions.AddRange(new[] { corichard, pintrand });
+ context.RunePage.AddRange(new[] { rp1, rp2 });
+ context.SaveChanges();
}
diff --git a/Sources/EntityFramework/RunePageEntity.cs b/Sources/EntityFramework/RunePageEntity.cs
index 7e4e1ce..842806b 100644
--- a/Sources/EntityFramework/RunePageEntity.cs
+++ b/Sources/EntityFramework/RunePageEntity.cs
@@ -11,9 +11,9 @@ namespace EntityFramework
public class RunePageEntity
{
[Key]
- public int Name { get; set; }
+ public string Name { get; set; }
- public Rune? Rune { get; set; }
+ public RuneEntity? Rune { get; set; }
//? voir si cela pause probleme
public Dictionary Dico = new Dictionary();
diff --git a/Sources/EntityFramework/champion.db b/Sources/EntityFramework/champion.db
index d4cefafe01938de63ed498a197e95c56e3139632..acdfad464be05e2f2dca24c7013c2beaa9a7f98d 100644
GIT binary patch
delta 2020
zcmaJ>U2NM_81?ma>e#XKC3TA##j9(nVntn-q@9M=q7hPW%GRY(+G#ByRo)i0))J?*
zDPrOw%LWL9keK|!q!Y14GEV&`7p
zbIv{A`L2BVI=*~8@Ls>%%WPlLwc&~39(J7x--1u&pTZx=6VhGjtn{^bL(+r)if{8j
z2EPqN_}91u{stdr*FV3eu(%rPahHP$)a!l}d;ux$f5B%^k9$Ozt1Nc&>R}C41>3oh
ze>FX~kXv)|S!*%x4>DFUPhTjhoSB?8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