From 3a53d55ff4a7b14cb6f89e7399b66aa49280697a Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Wed, 15 Mar 2023 17:27:20 +0100
Subject: [PATCH 1/5] =?UTF-8?q?:sparkles:=20Cr=C3=A9ation=20des=20classes?=
=?UTF-8?q?=20Rune,=20RunePage,=20famille=20et=20Cat=C3=A9gory?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Sources/EntityFramework/EnumCategory.cs | 18 +++++++++++++++
Sources/EntityFramework/EnumRuneFamily.cs | 15 ++++++++++++
Sources/EntityFramework/LoLDbContext.cs | 5 +++-
Sources/EntityFramework/RuneEntity.cs | 24 +++++++++++++++++++
Sources/EntityFramework/RunePageEntity.cs | 28 +++++++++++++++++++++++
5 files changed, 89 insertions(+), 1 deletion(-)
create mode 100644 Sources/EntityFramework/EnumCategory.cs
create mode 100644 Sources/EntityFramework/EnumRuneFamily.cs
create mode 100644 Sources/EntityFramework/RuneEntity.cs
create mode 100644 Sources/EntityFramework/RunePageEntity.cs
diff --git a/Sources/EntityFramework/EnumCategory.cs b/Sources/EntityFramework/EnumCategory.cs
new file mode 100644
index 0000000..8276ed2
--- /dev/null
+++ b/Sources/EntityFramework/EnumCategory.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public enum EnumCategory
+ {
+ Major,
+ Minor1,
+ Minor2,
+ Minor3,
+ OtherMinor1,
+ OtherMinor2
+ }
+}
diff --git a/Sources/EntityFramework/EnumRuneFamily.cs b/Sources/EntityFramework/EnumRuneFamily.cs
new file mode 100644
index 0000000..cbeacc0
--- /dev/null
+++ b/Sources/EntityFramework/EnumRuneFamily.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public enum EnumRuneFamily
+ {
+ Unknown,
+ Precision,
+ Domination
+ }
+}
diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs
index 7d61851..2c4c22b 100644
--- a/Sources/EntityFramework/LoLDbContext.cs
+++ b/Sources/EntityFramework/LoLDbContext.cs
@@ -11,6 +11,10 @@ namespace EntityFramework
{
public DbSet Champions { get; set; }
+ public DbSet Rune { get; set; }
+
+ public DbSet RunePage { get; set; }
+
public LoLDbContext()
{ }
@@ -47,7 +51,6 @@ namespace EntityFramework
modelBuilder.Entity().Property(entity => entity.Icon)
.IsRequired();
-
}
}
}
diff --git a/Sources/EntityFramework/RuneEntity.cs b/Sources/EntityFramework/RuneEntity.cs
new file mode 100644
index 0000000..c9de7da
--- /dev/null
+++ b/Sources/EntityFramework/RuneEntity.cs
@@ -0,0 +1,24 @@
+using Model;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ //[Table("Rune")]
+ public class RuneEntity
+ {
+ [Key]
+ public string Name;
+
+ public string Description;
+
+ public EnumRuneFamily Family;
+
+ public LargeImage Image;
+ }
+}
diff --git a/Sources/EntityFramework/RunePageEntity.cs b/Sources/EntityFramework/RunePageEntity.cs
new file mode 100644
index 0000000..e274bbf
--- /dev/null
+++ b/Sources/EntityFramework/RunePageEntity.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static Model.RunePage;
+
+namespace EntityFramework
+{
+ public class RunePageEntity
+ {
+ [Key]
+ public int Name { get; set; }
+
+ public Rune? Rune { get; set; }
+
+ //? voir si cela pause probleme
+ Dictionary Dico = new Dictionary();
+
+
+
+
+ public void CheckRunes(EnumCategory newRuneCategory){}
+ public void CheckFamilies(EnumCategory cat1, EnumCategory cat2){}
+ public void UpdateMajorFamily(EnumCategory minor, bool expectedValue){}
+ }
+}
--
2.36.3
From 556260df84627efbbe24f70185e53089f1b90e7c Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sun, 19 Mar 2023 15:36:42 +0100
Subject: [PATCH 2/5] 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; }
--
2.36.3
From 936922f77275375c30d80052f77f855d98508fd9 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sun, 19 Mar 2023 15:58:56 +0100
Subject: [PATCH 3/5] Mise a jour avec master et ajout d'info dans le
StubbedContext :zap:
---
Sources/EntityFramework/StubbedContext.cs | 29 ++++++++++++++---------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/Sources/EntityFramework/StubbedContext.cs b/Sources/EntityFramework/StubbedContext.cs
index 833f0c7..6e04c20 100644
--- a/Sources/EntityFramework/StubbedContext.cs
+++ b/Sources/EntityFramework/StubbedContext.cs
@@ -20,6 +20,9 @@ namespace EntityFramework
ChampionEntity corichard = new ChampionEntity {Name="Corichard", Bio="biobiobiobio", Icon="/a/a/a/a"};
ChampionEntity pintrand = new ChampionEntity {Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png" };
+
+ RuneEntity r1 = new RuneEntity( Name = "FirstRune", Description = "desc", Family = EnumRuneFamily.Domination)
+ RuneEntity r2 = new RuneEntity( Name = "SecondRune", Description = "desc", Family = EnumRuneFamily.Unknown)
//ChampionEntity corichard = new ChampionEntity() { Name = "Corichard", Bio = "biobiobiobio", Icon = "/a/a/a/a", Image = new LargeImageEntity { Base64 = "base" } };
//ChampionEntity pintrand = new ChampionEntity { Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png", Image = new LargeImageEntity { Base64 = "base" } };
@@ -27,17 +30,21 @@ namespace EntityFramework
modelBuilder.Entity().HasData(corichard, pintrand);
modelBuilder.Entity().HasData(new { Name = "aaaa", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon="/Icon.png", Price=10.0f },
- new { Name = "skin", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "bo", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "Joulie", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "Radiance", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "void", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "Radiance", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "void", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "DarkTheme", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "gold", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
- new { Name = "ruby", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f }
- );
+ new { Name = "skin", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "bo", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "Joulie", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "Radiance", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "void", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "Radiance", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "void", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "DarkTheme", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "gold", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f },
+ new { Name = "ruby", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f }
+ );
+
+ modelBuilder.Entity().HasData(new { Name = "RP1", Rune = r1, Champion = corichard},
+ new { Name = "RP2", Rune = r2, Champion = pintrand}
+ );
}
}
--
2.36.3
From 39eb15aeea2ca0aa3ef5629d64c254a8324bac22 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sun, 19 Mar 2023 16:25:17 +0100
Subject: [PATCH 4/5] bug fix :bug:
---
Sources/EntityFramework/StubbedContext.cs | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Sources/EntityFramework/StubbedContext.cs b/Sources/EntityFramework/StubbedContext.cs
index 6e04c20..3731035 100644
--- a/Sources/EntityFramework/StubbedContext.cs
+++ b/Sources/EntityFramework/StubbedContext.cs
@@ -18,11 +18,11 @@ namespace EntityFramework
{
base.OnModelCreating(modelBuilder);
- ChampionEntity corichard = new ChampionEntity {Name="Corichard", Bio="biobiobiobio", Icon="/a/a/a/a"};
- ChampionEntity pintrand = new ChampionEntity {Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png" };
-
- RuneEntity r1 = new RuneEntity( Name = "FirstRune", Description = "desc", Family = EnumRuneFamily.Domination)
- RuneEntity r2 = new RuneEntity( Name = "SecondRune", Description = "desc", Family = EnumRuneFamily.Unknown)
+ ChampionEntity corichard = new ChampionEntity { Name = "Corichard", Bio = "biobiobiobio", Icon = "/a/a/a/a" };
+ ChampionEntity pintrand = new ChampionEntity { Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png" };
+
+ RuneEntity r1 = new RuneEntity { Name = "FirstRune", Description = "desc", Family = EnumRuneFamily.Domination };
+ RuneEntity r2 = new RuneEntity { Name = "SecondRune", Description = "desc", Family = EnumRuneFamily.Unknown };
//ChampionEntity corichard = new ChampionEntity() { Name = "Corichard", Bio = "biobiobiobio", Icon = "/a/a/a/a", Image = new LargeImageEntity { Base64 = "base" } };
//ChampionEntity pintrand = new ChampionEntity { Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png", Image = new LargeImageEntity { Base64 = "base" } };
--
2.36.3
From 14ddb60602538368cb62029bcfc4bfa4a8716db0 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Thu, 23 Mar 2023 21:37:02 +0100
Subject: [PATCH 5/5] 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^>k*^oYRfHpoTu3(G5y4^aK9b6ETLWFGhKF
z%|ut4JEfMaVrAJbIi^##%ax8EAmHbZqy8li*T9cPh
z3v=l8CE!)lL~qTMt#gHrR(EVrX)8R^sAD$y{FJF1JFsm~Vn!Bqay3zY)cUMBH>+o+
z$$e&OYPbPuiMNrbq4N!_`>wd}O!m}5=k2n&^yy@7UO#2dlipISzv=LH-&=EWW71;@
z3iX$EcbYCXH}?eH@5RU6ccj5???_FWQzkiispL#5Ica)|6-wGuk=9DP+}bMr_;k)p
zpU5=Ipx{>9dd@s<=FCjWoY}6->%L#@P+z+(SsXeW=~6G6?s{0a_w*I-wX&d$37(qM(6{8;=){k*j2Q7^JBgYEiBv4_H4
zYDz^_KhMx*{spGw!
z4A;%pewQ@N-C^KPEvnywK?C8WnusMvW21@DL~L|yEWS{*oJ;;~FCH0*jU>bxifqA%
zhLgghkuv#=b6_*@Gkgqhf?bP7=Hb~sE}-qxn5^xTS1jkkIlDxD>GLILWZ7AK5(oOp
zVyd)apI@?8cC8*|-ItDyBjmn+Y=1=b)o(Je1-IcQ{7KZmf};}F5S8X++>e@4xEl|l
zl(k&8Y)3zBt-O*iupz7oPN_(mQYd_p<#dUIEe8I9Kj1EG5y2ne5YMrymu`Z`^+7zq
zvWjI{9AcxERd=z$z;CcYhz|+rJ1_*SBA>+3Q5^GFL4?Kza8$6Y50{^lynI-=$G~53
zuNKX2!hpbHMag9o1Q$eDiRQBL`W7raVBl|fKw!T>pC?67Y!_Ap0;%h4GH@R@Negeo
z!7z(8g~mXTfN;OkOoC86+bj^<_hG~D`bdP+lxA|Cc!cX$gmz8`A9c}(UVtQr?5_~s
IRr6>1|8f6kg#Z8m
delta 503
zcmZozz}m2Yd4fDIF9QOwPt>uI;o-<-;Jd`XmiIc}LS7r5SKRJAn>qWrWjKCw-Ad<1Arhlx@7aRHsq$p3@O;
z*c5~O$iW}Q!2g;51^*rX^ZW<-xA9Noj{w0!pSy_38y!>3C19Nhc
zGV{T7W^#TWn8C@$DhdoNr^KQZ9#&RqAk#4?v$!O&h?|8~62!|c&PdGTVrCTwa}skh
zIhnvZ95aeCxfvm95=)BmD?qO1;9tzZ|Be4G|6~3e{Ac(N^Dk!N-v)F}H~;j0e?}p1
z4jyJ%MwnaJIhaKmK^C)dGfOi34iRD889jU0AtmDUH||9
--
2.36.3