From 3da8ab952aa5b7aaa253b1568a33a305e2c2f4f2 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sat, 25 Mar 2023 16:29:35 +0100
Subject: [PATCH] :zap: Ajout des liaisons One to many pour champion et skill,
et pour runepage et rune, migration fonctionnel avec comme context le
loldbcontext, mais pas avec le stubbed
---
Sources/EntityFramework/LoLDbContext.cs | 48 +++-
.../20230325150121_MigrSkill.Designer.cs | 225 ++++++++++++++++++
.../Migrations/20230325150121_MigrSkill.cs | 197 +++++++++++++++
.../Migrations/LoLDbContextModelSnapshot.cs | 222 +++++++++++++++++
Sources/EntityFramework/Program.cs | 167 +++++++------
Sources/EntityFramework/RuneEntity.cs | 4 +
Sources/EntityFramework/RunePageEntity.cs | 9 +-
Sources/EntityFramework/SkillEntity.cs | 4 +
Sources/EntityFramework/SkinEntity.cs | 4 +-
Sources/EntityFramework/StubbedContext.cs | 33 +++
Sources/EntityFramework/champion.db | Bin 0 -> 90112 bytes
11 files changed, 831 insertions(+), 82 deletions(-)
create mode 100644 Sources/EntityFramework/Migrations/20230325150121_MigrSkill.Designer.cs
create mode 100644 Sources/EntityFramework/Migrations/20230325150121_MigrSkill.cs
create mode 100644 Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
create mode 100644 Sources/EntityFramework/champion.db
diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs
index 042b646..8dbfbb0 100644
--- a/Sources/EntityFramework/LoLDbContext.cs
+++ b/Sources/EntityFramework/LoLDbContext.cs
@@ -13,8 +13,9 @@ namespace EntityFramework
public DbSet Skins { get; set; }
- public DbSet Image { get; set; }
+ public DbSet Skills { get; set; }
+ public DbSet Image { get; set; }
public DbSet Rune { get; set; }
@@ -46,7 +47,8 @@ namespace EntityFramework
modelBuilder.Entity().Property(entity => entity.Name)
.IsRequired()
- .HasMaxLength(50);
+ .HasMaxLength(50)
+ .ValueGeneratedOnAdd();
modelBuilder.Entity().Property(entity => entity.Bio)
.HasMaxLength(500)
@@ -76,11 +78,32 @@ namespace EntityFramework
.HasForeignKey("ChampionEntityForeignKey");
+ /// One to many
+ /// ChampionEntity ---> * SkillEntity
+ //création de la table ChampionEntity
+ //modelBuilder.Entity().HasKey(c => c.Name); //définition de la clé primaire
+ //modelBuilder.Entity().Property(c => c.Name)
+ // .ValueGeneratedOnAdd(); //définition du mode de génération de la clé : génération à l'insertion
+
+ //création de la table SkillEntity
+ modelBuilder.Entity().HasKey(s => s.Name); //définition de la clé primaire
+ modelBuilder.Entity().Property(s => s.Name)
+ .ValueGeneratedOnAdd(); //définition du mode de génération de la clé : génération à l'insertion
+ // Add the shadow property to the model
+ modelBuilder.Entity()
+ .Property("ChampionEntityToSkillForeignKey");
+
+ // Use the shadow property as a foreign key
+ modelBuilder.Entity()
+ .HasOne(s => s.Champion)
+ .WithMany(c => c.Skills)
+ .HasForeignKey("ChampionEntityToSkillForeignKey");
- // Many to Many ChampionEntity - RunePageEntity
- modelBuilder.Entity().HasKey(entity => entity.Name);
+
+ /// Many to Many ChampionEntity - RunePageEntity
+ modelBuilder.Entity().HasKey(entity => entity.Name);
modelBuilder.Entity().HasKey(entity => entity.Name);
modelBuilder.Entity().ToTable("RunePage");
@@ -95,6 +118,23 @@ namespace EntityFramework
.HasMany(c => c.RunePageEntities)
.WithMany(r => r.Champion);
//.HasForeignKey("AlbumForeignKey");
+
+
+
+ //création de la table RuneEntity
+ modelBuilder.Entity().HasKey(r => r.Name); //définition de la clé primaire
+ modelBuilder.Entity().Property(r => r.Name)
+ .ValueGeneratedOnAdd(); //définition du mode de génération de la clé : génération à l'insertion
+
+ modelBuilder.Entity()
+ .Property("RuneForeignKey");
+
+ modelBuilder.Entity()
+ .HasOne(r => r.RunePage)
+ .WithMany(rp => rp.Runes)
+ .HasForeignKey("RuneForeignKey");
+
+
}
}
}
diff --git a/Sources/EntityFramework/Migrations/20230325150121_MigrSkill.Designer.cs b/Sources/EntityFramework/Migrations/20230325150121_MigrSkill.Designer.cs
new file mode 100644
index 0000000..79aa753
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/20230325150121_MigrSkill.Designer.cs
@@ -0,0 +1,225 @@
+//
+using EntityFramework;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EntityFramework.Migrations
+{
+ [DbContext(typeof(LoLDbContext))]
+ [Migration("20230325150121_MigrSkill")]
+ partial class MigrSkill
+ {
+ ///
+ protected override void BuildTargetModel(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")
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("Bio")
+ .IsRequired()
+ .HasMaxLength(500)
+ .HasColumnType("string")
+ .HasColumnName("Bio");
+
+ b.Property("Icon")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Image")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Champions", (string)null);
+ });
+
+ modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Base64")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Image");
+ });
+
+ modelBuilder.Entity("EntityFramework.RuneEntity", b =>
+ {
+ b.Property("Name")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("RuneForeignKey")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.HasIndex("RuneForeignKey");
+
+ 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")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("ChampionEntityToSkillForeignKey")
+ .HasColumnType("TEXT");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Name");
+
+ b.HasIndex("ChampionEntityToSkillForeignKey");
+
+ b.ToTable("Skills");
+ });
+
+ modelBuilder.Entity("EntityFramework.SkinEntity", b =>
+ {
+ b.Property("Name")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("ChampionEntityForeignKey")
+ .HasColumnType("TEXT");
+
+ b.Property("Description")
+ .HasColumnType("TEXT");
+
+ b.Property("Icon")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Image")
+ .HasColumnType("TEXT");
+
+ b.Property("Price")
+ .HasColumnType("REAL");
+
+ b.HasKey("Name");
+
+ b.HasIndex("ChampionEntityForeignKey");
+
+ 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.RuneEntity", b =>
+ {
+ b.HasOne("EntityFramework.RunePageEntity", "RunePage")
+ .WithMany("Runes")
+ .HasForeignKey("RuneForeignKey");
+
+ b.Navigation("RunePage");
+ });
+
+ 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", "Champion")
+ .WithMany("Skills")
+ .HasForeignKey("ChampionEntityToSkillForeignKey");
+
+ b.Navigation("Champion");
+ });
+
+ modelBuilder.Entity("EntityFramework.SkinEntity", b =>
+ {
+ b.HasOne("EntityFramework.ChampionEntity", "Champion")
+ .WithMany("skins")
+ .HasForeignKey("ChampionEntityForeignKey");
+
+ b.Navigation("Champion");
+ });
+
+ modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
+ {
+ b.Navigation("Skills");
+
+ b.Navigation("skins");
+ });
+
+ modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
+ {
+ b.Navigation("Runes");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Sources/EntityFramework/Migrations/20230325150121_MigrSkill.cs b/Sources/EntityFramework/Migrations/20230325150121_MigrSkill.cs
new file mode 100644
index 0000000..4631e3a
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/20230325150121_MigrSkill.cs
@@ -0,0 +1,197 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace EntityFramework.Migrations
+{
+ ///
+ public partial class MigrSkill : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Champions",
+ columns: table => new
+ {
+ Name = table.Column(type: "TEXT", maxLength: 50, nullable: false),
+ Bio = table.Column(type: "string", maxLength: 500, nullable: false),
+ Icon = table.Column(type: "TEXT", nullable: false),
+ Image = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Champions", x => x.Name);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Image",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Base64 = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Image", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Skills",
+ columns: table => new
+ {
+ Name = table.Column(type: "TEXT", nullable: false),
+ Type = table.Column(type: "INTEGER", nullable: false),
+ Description = table.Column(type: "TEXT", nullable: false),
+ ChampionEntityToSkillForeignKey = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Skills", x => x.Name);
+ table.ForeignKey(
+ name: "FK_Skills_Champions_ChampionEntityToSkillForeignKey",
+ column: x => x.ChampionEntityToSkillForeignKey,
+ principalTable: "Champions",
+ principalColumn: "Name");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Skins",
+ columns: table => new
+ {
+ Name = table.Column(type: "TEXT", nullable: false),
+ Description = table.Column(type: "TEXT", nullable: true),
+ Icon = table.Column(type: "TEXT", nullable: false),
+ Image = table.Column(type: "TEXT", nullable: true),
+ Price = table.Column(type: "REAL", nullable: false),
+ ChampionEntityForeignKey = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Skins", x => x.Name);
+ table.ForeignKey(
+ name: "FK_Skins_Champions_ChampionEntityForeignKey",
+ column: x => x.ChampionEntityForeignKey,
+ principalTable: "Champions",
+ 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 =>
+ {
+ table.PrimaryKey("PK_ChampionEntityRunePageEntity", x => new { x.ChampionName, x.RunePageEntitiesName });
+ table.ForeignKey(
+ name: "FK_ChampionEntityRunePageEntity_Champions_ChampionName",
+ column: x => x.ChampionName,
+ principalTable: "Champions",
+ principalColumn: "Name",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Rune",
+ columns: table => new
+ {
+ Name = table.Column(type: "TEXT", nullable: false),
+ RuneForeignKey = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Rune", x => x.Name);
+ });
+
+ 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.CreateIndex(
+ name: "IX_ChampionEntityRunePageEntity_RunePageEntitiesName",
+ table: "ChampionEntityRunePageEntity",
+ column: "RunePageEntitiesName");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Rune_RuneForeignKey",
+ table: "Rune",
+ column: "RuneForeignKey");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RunePage_RuneName",
+ table: "RunePage",
+ column: "RuneName");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Skills_ChampionEntityToSkillForeignKey",
+ table: "Skills",
+ column: "ChampionEntityToSkillForeignKey");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Skins_ChampionEntityForeignKey",
+ table: "Skins",
+ column: "ChampionEntityForeignKey");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_ChampionEntityRunePageEntity_RunePage_RunePageEntitiesName",
+ table: "ChampionEntityRunePageEntity",
+ column: "RunePageEntitiesName",
+ principalTable: "RunePage",
+ principalColumn: "Name",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Rune_RunePage_RuneForeignKey",
+ table: "Rune",
+ column: "RuneForeignKey",
+ principalTable: "RunePage",
+ principalColumn: "Name");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Rune_RunePage_RuneForeignKey",
+ table: "Rune");
+
+ migrationBuilder.DropTable(
+ name: "ChampionEntityRunePageEntity");
+
+ migrationBuilder.DropTable(
+ name: "Image");
+
+ migrationBuilder.DropTable(
+ name: "Skills");
+
+ migrationBuilder.DropTable(
+ name: "Skins");
+
+ migrationBuilder.DropTable(
+ name: "Champions");
+
+ migrationBuilder.DropTable(
+ name: "RunePage");
+
+ migrationBuilder.DropTable(
+ name: "Rune");
+ }
+ }
+}
diff --git a/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
new file mode 100644
index 0000000..c1b9974
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
@@ -0,0 +1,222 @@
+//
+using EntityFramework;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EntityFramework.Migrations
+{
+ [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")
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("Bio")
+ .IsRequired()
+ .HasMaxLength(500)
+ .HasColumnType("string")
+ .HasColumnName("Bio");
+
+ b.Property("Icon")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Image")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Champions", (string)null);
+ });
+
+ modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Base64")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Image");
+ });
+
+ modelBuilder.Entity("EntityFramework.RuneEntity", b =>
+ {
+ b.Property("Name")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("RuneForeignKey")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.HasIndex("RuneForeignKey");
+
+ 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")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("ChampionEntityToSkillForeignKey")
+ .HasColumnType("TEXT");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Name");
+
+ b.HasIndex("ChampionEntityToSkillForeignKey");
+
+ b.ToTable("Skills");
+ });
+
+ modelBuilder.Entity("EntityFramework.SkinEntity", b =>
+ {
+ b.Property("Name")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("ChampionEntityForeignKey")
+ .HasColumnType("TEXT");
+
+ b.Property("Description")
+ .HasColumnType("TEXT");
+
+ b.Property("Icon")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Image")
+ .HasColumnType("TEXT");
+
+ b.Property("Price")
+ .HasColumnType("REAL");
+
+ b.HasKey("Name");
+
+ b.HasIndex("ChampionEntityForeignKey");
+
+ 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.RuneEntity", b =>
+ {
+ b.HasOne("EntityFramework.RunePageEntity", "RunePage")
+ .WithMany("Runes")
+ .HasForeignKey("RuneForeignKey");
+
+ b.Navigation("RunePage");
+ });
+
+ 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", "Champion")
+ .WithMany("Skills")
+ .HasForeignKey("ChampionEntityToSkillForeignKey");
+
+ b.Navigation("Champion");
+ });
+
+ modelBuilder.Entity("EntityFramework.SkinEntity", b =>
+ {
+ b.HasOne("EntityFramework.ChampionEntity", "Champion")
+ .WithMany("skins")
+ .HasForeignKey("ChampionEntityForeignKey");
+
+ b.Navigation("Champion");
+ });
+
+ modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
+ {
+ b.Navigation("Skills");
+
+ b.Navigation("skins");
+ });
+
+ modelBuilder.Entity("EntityFramework.RunePageEntity", b =>
+ {
+ b.Navigation("Runes");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Sources/EntityFramework/Program.cs b/Sources/EntityFramework/Program.cs
index 56915f8..378e412 100644
--- a/Sources/EntityFramework/Program.cs
+++ b/Sources/EntityFramework/Program.cs
@@ -38,64 +38,101 @@ using ( var context = new LoLDbContext())
context.SaveChanges();
-IDataManager dataManager = new EFDataManager();
-IChampionsManager championsManager = dataManager.ChampionsMgr;
-IEnumerable champions = await championsManager.GetItemsByName("A", 0, 1);
-Console.WriteLine(champions.First().Name);
-
-
-//using ( var context = new LoLDbContext())
-//{
-// //context.Add(new ChampionEntity{ Name = "test", Bio = "test", Icon = "test" } );
-// context.SaveChanges();
-
-// ChampionEntity champ = context.Find("Akali");
-
-// if( champ != null)
-// {
-// Console
-// .WriteLine(champ.ToString());
-
-// }
-// else
-// {
-// Console.WriteLine("Not Found");
-// }
-
-// //Test BDD Skills
-// 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 };
-
-// champSkill.AddSkill(new SkillEntity { Name = "Skill1", Description = "desc", Type = SkillType.Unknown });
-// champSkill.AddSkill(s2);
-// champSkill.AddSkill(s3);
-
-// context.Add(champSkill);
-
-// context.SaveChanges();
+ IDataManager dataManager = new EFDataManager();
+ IChampionsManager championsManager = dataManager.ChampionsMgr;
+ IEnumerable champions = await championsManager.GetItemsByName("A", 0, 1);
+ //Console.WriteLine(champions.First().Name);
+
+
+ //using ( var context = new LoLDbContext())
+ //{
+ // //context.Add(new ChampionEntity{ Name = "test", Bio = "test", Icon = "test" } );
+ // context.SaveChanges();
+
+ // ChampionEntity champ = context.Find("Akali");
+
+ // if( champ != null)
+ // {
+ // Console
+ // .WriteLine(champ.ToString());
+
+ // }
+ // else
+ // {
+ // Console.WriteLine("Not Found");
+ // }
+
+ // //Test BDD Skills
+ // 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 };
+
+ // champSkill.AddSkill(new SkillEntity { Name = "Skill1", Description = "desc", Type = SkillType.Unknown });
+ // champSkill.AddSkill(s2);
+ // champSkill.AddSkill(s3);
+
+ // context.Add(champSkill);
+
+ // context.SaveChanges();
+
+
+ // //OneToMany
+ // Console.WriteLine("Champions : ");
+ // foreach (var champi in context.Champions.Include(a => a.skins))
+ // {
+ // Console.WriteLine($"\t{champi.Name} : {champi.Bio}");
+ // foreach (var s in champi.skins)
+ // {
+ // Console.WriteLine($"\t\t{s.Name}");
+ // }
+ // }
+
+ // Console.WriteLine();
+
+ // Console.WriteLine("Skin :");
+ // foreach (var s in context.Skins)
+ // {
+ // Console.WriteLine($"\t{s.Name}: {s.Description} (Champion : {s.Champion.Name})");
+ // }
+
+ Console.WriteLine("\nAjout d'un Champion et 6 Skins...\n");
+
+ ChampionEntity captainMarvel = new ChampionEntity { Name = "Captain Marvel", Bio = "Mais que fait un avenger ici ??", Icon = "Icon.png" };
+ SkinEntity[] skins = { new SkinEntity {Name = "La Fiesta", Champion = captainMarvel},
+ new SkinEntity { Name = "Five Hundred Miles High", Champion = captainMarvel },
+ new SkinEntity { Name = "Captain Marvel", Champion = captainMarvel },
+ new SkinEntity { Name = "Time's Lie", Champion = captainMarvel },
+ new SkinEntity { Name = "Lush Life", Champion = captainMarvel },
+ new SkinEntity { Name = "Day Waves", Champion = captainMarvel }
+ };
+ foreach (var s in skins)
+ {
+ captainMarvel.skins.Add(s);
+ }
+ context.Add(captainMarvel);
+ context.SaveChanges();
-// //OneToMany
-// Console.WriteLine("Champions : ");
-// foreach (var champi in context.Champions.Include(a => a.skins))
-// {
-// Console.WriteLine($"\t{champi.Name} : {champi.Bio}");
-// foreach (var s in champi.skins)
-// {
-// Console.WriteLine($"\t\t{s.Name}");
-// }
-// }
-// Console.WriteLine();
+ //OnetoMany Skill
+ ChampionEntity Levram = new ChampionEntity { Name = "Captain Levram", Bio="bio", Icon="/img" };
+ SkillEntity[] morceaux = { new SkillEntity { Name = "La Fiesta", Description="SkillDesc", Type=EntityFramework.SkillType.Unknown, Champion= Levram },
+ new SkillEntity { Name = "berserk", Description="SkillDesc1", Type=EntityFramework.SkillType.Unknown, Champion= Levram },
+ new SkillEntity { Name = "taunt", Description = "SkillDesc2", Type = EntityFramework.SkillType.Unknown, Champion = Levram },
+ new SkillEntity { Name = "fear", Description = "SkillDesc3", Type = EntityFramework.SkillType.Unknown, Champion = Levram },
+ new SkillEntity { Name = "flashHeal", Description = "SkillDesc4", Type = EntityFramework.SkillType.Unknown, Champion = Levram },
+ new SkillEntity { Name = "bubbuletp", Description = "SkillDesc5", Type = EntityFramework.SkillType.Unknown, Champion = Levram }
+ };
+ foreach (var m in morceaux)
+ {
+ Levram.Skills.Add(m);
+ }
+
+ context.Add(Levram);
+ context.SaveChanges();
-// Console.WriteLine("Skin :");
-// foreach (var s in context.Skins)
-// {
-// Console.WriteLine($"\t{s.Name}: {s.Description} (Champion : {s.Champion.Name})");
-// }
var r1 = new RuneEntity { Name = "Rune1", Description = "aaa", Family = EnumRuneFamily.Domination, Image = new LargeImage("base") };
@@ -109,24 +146,4 @@ Console.WriteLine(champions.First().Name);
context.Champions.AddRange(new[] { corichard, pintrand });
context.RunePage.AddRange(new[] { rp1, rp2 });
context.SaveChanges();
-}
-// Console.WriteLine("\nAjout d'un Champion et 6 Skins...\n");
-
-// ChampionEntity captainMarvel = new ChampionEntity { Name = "Captain Marvel", Bio="Mais que fait un avenger ici ??", Icon="Icon.png"};
-// SkinEntity[] skins = { new SkinEntity {Name = "La Fiesta", Champion = captainMarvel},
-// new SkinEntity { Name = "Five Hundred Miles High", Champion = captainMarvel },
-// new SkinEntity { Name = "Captain Marvel", Champion = captainMarvel },
-// new SkinEntity { Name = "Time's Lie", Champion = captainMarvel },
-// new SkinEntity { Name = "Lush Life", Champion = captainMarvel },
-// new SkinEntity { Name = "Day Waves", Champion = captainMarvel }
-// };
-// foreach (var s in skins)
-// {
-// captainMarvel.skins.Add(s);
-// }
-
-// context.Add(captainMarvel);
-// context.SaveChanges();
-
-
-//}
+}
\ No newline at end of file
diff --git a/Sources/EntityFramework/RuneEntity.cs b/Sources/EntityFramework/RuneEntity.cs
index c9de7da..5047c19 100644
--- a/Sources/EntityFramework/RuneEntity.cs
+++ b/Sources/EntityFramework/RuneEntity.cs
@@ -20,5 +20,9 @@ namespace EntityFramework
public EnumRuneFamily Family;
public LargeImage Image;
+
+
+ //OtM
+ public RunePageEntity RunePage { get; set; }
}
}
diff --git a/Sources/EntityFramework/RunePageEntity.cs b/Sources/EntityFramework/RunePageEntity.cs
index 842806b..61270de 100644
--- a/Sources/EntityFramework/RunePageEntity.cs
+++ b/Sources/EntityFramework/RunePageEntity.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
@@ -16,7 +17,11 @@ namespace EntityFramework
public RuneEntity? Rune { get; set; }
//? voir si cela pause probleme
- public Dictionary Dico = new Dictionary();
+ //public Dictionary Dico = new Dictionary();
+
+ // One to many pour l'instant, voir si on retransforme en dico :
+ public ICollection Runes { get; set; }
+
// Pour le many to many Champion *<---->* RunePage
public ICollection Champion{ get; set; }
diff --git a/Sources/EntityFramework/SkillEntity.cs b/Sources/EntityFramework/SkillEntity.cs
index 505a427..22ed683 100644
--- a/Sources/EntityFramework/SkillEntity.cs
+++ b/Sources/EntityFramework/SkillEntity.cs
@@ -49,5 +49,9 @@ namespace EntityFramework
// this.Description = Description;
// this.Type = Type;
//}
+
+
+ // One to many with champion :
+ public ChampionEntity Champion { get; set; }
}
}
diff --git a/Sources/EntityFramework/SkinEntity.cs b/Sources/EntityFramework/SkinEntity.cs
index e9650b3..f92a44d 100644
--- a/Sources/EntityFramework/SkinEntity.cs
+++ b/Sources/EntityFramework/SkinEntity.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -8,7 +9,8 @@ namespace EntityFramework
{
public class SkinEntity //ONE TO MANY
{
-
+
+ [Key]
public string? Name { get; set; }
public string? Description { get; set; }
diff --git a/Sources/EntityFramework/StubbedContext.cs b/Sources/EntityFramework/StubbedContext.cs
index 3731035..4bf0d84 100644
--- a/Sources/EntityFramework/StubbedContext.cs
+++ b/Sources/EntityFramework/StubbedContext.cs
@@ -42,10 +42,43 @@ namespace EntityFramework
new { Name = "ruby", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f }
);
+ //Skills
+ modelBuilder.Entity().HasData(new { Name="Skill", Description="Desc", Type= SkillType.Basic, ChampionEntityToSkillForeignKey= "Corichard" },
+ new { Name = "Skill2", Description = "Desc", Type = SkillType.Basic, ChampionEntityToSkillForeignKey = "Corichard" },
+ new { Name = "Skill3", Description = "Desc", Type = SkillType.Passive, ChampionEntityToSkillForeignKey = "Corichard" },
+ new { Name = "Skill4", Description = "Desc", Type = SkillType.Unknown, ChampionEntityToSkillForeignKey = "Corichard" },
+ new { Name = "Skill5", Description = "Desc", Type = SkillType.Basic, ChampionEntityToSkillForeignKey = "Corichard" },
+ new { Name = "Skill6", Description = "Desc", Type = SkillType.Basic, ChampionEntityToSkillForeignKey = "Corichard" },
+ new { Name = "Skill10", Description = "Desc", Type = SkillType.Basic, ChampionEntityToSkillForeignKey = "Pintrand" },
+ new { Name = "Skill11", Description = "Desc", Type = SkillType.Unknown, ChampionEntityToSkillForeignKey = "Pintrand" },
+ new { Name = "Skill12", Description = "Desc", Type = SkillType.Passive, ChampionEntityToSkillForeignKey = "Pintrand" },
+ new { Name = "Skill13", Description = "Desc", Type = SkillType.Basic, ChampionEntityToSkillForeignKey = "Pintrand" },
+ new { Name = "Skill14", Description = "Desc", Type = SkillType.Basic, ChampionEntityToSkillForeignKey = "Pintrand" }
+ );
+
+
+
+
modelBuilder.Entity().HasData(new { Name = "RP1", Rune = r1, Champion = corichard},
new { Name = "RP2", Rune = r2, Champion = pintrand}
);
+
+
+
+ RunePageEntity rp11 = new RunePageEntity { Name = "rp11"};
+ RunePageEntity rp21 = new RunePageEntity { Name = "rp21"};
+
+ modelBuilder.Entity().HasData(rp11, rp21);
+
+ modelBuilder.Entity().HasData(new { Name = "Rune", Description = "Desc", Famille = EnumRuneFamily.Domination, RuneForeignKey = "rp11" },
+ new{Name = "Rune2", Description = "Desc",Famille = EnumRuneFamily.Domination,RuneForeignKey = "rp11"},
+ new { Name = "Rune3", Description = "Desc", Famille = EnumRuneFamily.Domination, RuneForeignKey = "rp21" },
+ new { Name = "Rune4", Description = "Desc", Famille = EnumRuneFamily.Domination, RuneForeignKey = "rp21" }
+ );
}
+
+
+
}
}
diff --git a/Sources/EntityFramework/champion.db b/Sources/EntityFramework/champion.db
new file mode 100644
index 0000000000000000000000000000000000000000..c71528bf67720357cd407d1a5b1ca93117b28420
GIT binary patch
literal 90112
zcmeI*U5pz?0SEBi9k1=ZuepokZr$K`V?rA%Q5rie~F`t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