From 957ace65860fb106ad02ee0976b14fc2118f5bdf Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Sat, 4 Feb 2023 10:53:42 +0100 Subject: [PATCH 1/7] Pull Master --- .../EntityFrameworkLOL.csproj | 3 +- Sources/EntityFrameworkLOL/Program.cs | 99 ++++++++++++++++++- 2 files changed, 99 insertions(+), 3 deletions(-) diff --git a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj index d683ca4..26d60a1 100644 --- a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj +++ b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj @@ -1,10 +1,11 @@ - + Exe net6.0 enable enable + $(MSBuildProjectDirectory) diff --git a/Sources/EntityFrameworkLOL/Program.cs b/Sources/EntityFrameworkLOL/Program.cs index 3751555..e0798bd 100644 --- a/Sources/EntityFrameworkLOL/Program.cs +++ b/Sources/EntityFrameworkLOL/Program.cs @@ -1,2 +1,97 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using EntityFrameworkLOL.DBContexts; +using EntityFrameworkLOL.Entities; +using System.Linq; +using System; +using System.Text; + +class Program +{ + static void Main(string[] args) + { + ChampionEntity akali = new ChampionEntity { Name = "Akali" }; + ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox" }; + ChampionEntity ahri = new ChampionEntity { Name = "Ahri" }; + ChampionEntity bard = new ChampionEntity { Name = "Bard" }; + ChampionEntity alistar = new ChampionEntity { Name = "Alistar" }; + ChampionEntity akshan = new ChampionEntity { Name = "Akshan" }; + + using (var context = new ChampionContext()) + { + // Crée des champions et les insère dans la base + Console.WriteLine("Creates and inserts new Champions"); + context.Add(akali); + context.Add(aatrox); + context.Add(ahri); + context.Add(bard); + context.Add(alistar); + context.Add(akshan); + context.SaveChanges(); + Console.WriteLine("Creates and executes a query retrieving the first Champion of the database whose name starts with an \"A\":"); + var aChampion = context.Champion + .Where(c => c.Name.StartsWith("A")) + .First(); + Console.WriteLine($"{aChampion.Name} (with bio : {aChampion.Bio}"); + } + + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" }; + RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" }; + RuneEntity alacrity = new RuneEntity { Name = "Legend : Alacrity", Description = "" }; + RuneEntity tenacity = new RuneEntity { Name = "Legend : Tenacity", Description = "" }; + RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" }; + RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" }; + + using (var context = new RuneContext()) + { + // Crée des Runes et les insère dans la base + Console.WriteLine("Creates and inserts new Runes"); + context.Add(conqueror); + context.Add(thriumph); + context.Add(alacrity); + context.Add(tenacity); + context.Add(laststand); + context.Add(laststand2); + context.SaveChanges(); + Console.WriteLine("Creates and executes a query retrieving the first Runes of the database whose name starts with an \"L\":"); + var lRune = context.Rune + .Where(r => r.Name.StartsWith("L")) + .First(); + Console.WriteLine($"{lRune.Name} (with Description : {lRune.Description}"); + } + + SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" }; + SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" }; + SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" }; + SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" }; + SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" }; + SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" }; + + using (var context = new SkinContext()) + { + // Crée des Skins et les insère dans la base + Console.WriteLine("Creates and inserts new Skins"); + context.Add(stinger); + context.Add(infernal); + context.Add(allStar); + context.Add(justicar); + context.Add(mecha); + context.Add(seaHunter); + context.SaveChanges(); + Console.WriteLine("Creates and executes a query retrieving the first Skins of the database whose name starts with an \"I\":"); + var iSkin = context.Skin + .Where(s => s.Name.StartsWith("I")) + .First(); + Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}"); + + Console.WriteLine("Updates the name of the Infernal Skin"); + iSkin.Name = "Infernal of Hell (Wallah)"; + context.SaveChanges(); + Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}"); + + Console.WriteLine("Deletes one item from the database"); + var droid = context.Skin + .SingleOrDefault(s => s.Name.Equals("Infernal")); + context.Remove(droid); + context.SaveChanges(); + } + } +} \ No newline at end of file From 6650ce89e06f84d2f8d230e48c228cfb35c07160 Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Sat, 4 Feb 2023 11:56:49 +0100 Subject: [PATCH 2/7] push EF database --- .../DBContexts/SQLiteContext.cs | 11 ++- Sources/EntityFrameworkLOL/DBLOL.db | Bin 45056 -> 45056 bytes .../Entities/ChampionEntity.cs | 5 +- .../EntityFrameworkLOL/Entities/RuneEntity.cs | 3 + .../EntityFrameworkLOL/Entities/SkinEntity.cs | 3 + ...0230202105714_MigrationWallah2.Designer.cs | 38 -------- .../20230202105714_MigrationWallah2.cs | 33 ------- ...0230204102144_MigrationWallah3.Designer.cs | 81 ++++++++++++++++++ .../20230204102144_MigrationWallah3.cs | 69 +++++++++++++++ .../Migrations/SQLiteContextModelSnapshot.cs | 47 +++++++++- Sources/EntityFrameworkLOL/Program.cs | 56 +++++++----- 11 files changed, 247 insertions(+), 99 deletions(-) delete mode 100644 Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.Designer.cs delete mode 100644 Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs diff --git a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs index 8c31903..511998a 100644 --- a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs +++ b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs @@ -5,11 +5,18 @@ namespace EntityFrameworkLOL.DBContexts { class SQLiteContext : DbContext { - /*public DbSet Champion { get; set; } - public DbSet Skin { get; set; }*/ + public DbSet Champion { get; set; } + public DbSet Skin { get; set; } public DbSet Rune { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseSqlite($"Data Source=DBLOL.db"); + + public SQLiteContext() + { } + + public SQLiteContext(DbContextOptions options) + : base(options) + { } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBLOL.db b/Sources/EntityFrameworkLOL/DBLOL.db index e1ce9c74d5f9994634429e98dacb045436979531..858361157c2dffac2361045c41627337790772a0 100644 GIT binary patch delta 1486 zcma)*O>7%Q6o6+v>vini+2>MOCNW#qL8VEWq#MVj6`-PZWVOMLi(*%lKShhPjaS*M z+x5CCT-qYMAZww3Ka;%35h?c5*&Ez*u;)nm6hJi z&b+_xy_q?GD|G%=Xf3rXM+gx+!s9&h>iBdzME#al8FTOO2IQ;w9WFeelB0CjI)@E-*CxTG5t+3>Hj4uvDIw26VK1HvAzh;%KscedajsPcPK|3jNu)Y5U36U8Enjc(kOGu)6UA0hA+T!stq0%Spye~{mk*W@Mn z2sT-jTl+*>NM^Lmw3gAbQ(9&!n_ZZ*mR!TL>dw=KZ5y@eLzCKMW?!t&P&=$?cQK6i z8y?gS-^Fl%7B)WIb2NZFOJEb;hu6S`5{!X>nAhaj<+BKRQf@s&3*0>z#eSPR;>C8@ z+=(pOW0RTE4j!7yF8H7CiTmLL|LlejhyWLPcpH9&@8M1O1TJpu(#}CEF7RYlpSi6YrqfU8y5mcXCw5j;C4KG}L2F$1~k1q9)m#S*;mC>lOB7v*B4) z!wveVFx|E%uqYRcmlf8HCL&Xcl|9Q@GToptB#sAzNMFMj@DW^rD@gP*68%gbexmEt zoz?m&HGumMDJIbEU}4%zH^9>loJi?58zy8uFsSKr#yT+YCwv2u8*m*D>MFv#1qG3& zxDK))(=@l;gK(54xpoV936H$n0UD&~QinvUM7vquU5mt(Kpmuuq70x!P=xLpQ+@~k E0@T)tRR910 delta 484 zcmZp8z|`=7X@az%2m=EHHx#o0X^DwC#)={gdht@c{6832_+%LPF7dDBli^#*D+GZ& z+&tWy6$Nf{O^)XNAuKA&*pyn5n3R(moSm5m!W@&cd1R#h5_5S!GW3cA1X2jX$Vyxl zlt4n0CvxlJuuq+ZO&nq$H%KMKKGw~b_>34uIQVul@ZaEH&)>!$%WuNZ&G(3J=VnEN zg?yWL%6WsNA2IOX -using EntityFrameworkLOL.DBContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EntityFrameworkLOL.Migrations -{ - [DbContext(typeof(SQLiteContext))] - [Migration("20230202105714_MigrationWallah2")] - partial class MigrationWallah2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => - { - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Name"); - - b.ToTable("Rune"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.cs b/Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.cs deleted file mode 100644 index 0150ec7..0000000 --- a/Sources/EntityFrameworkLOL/Migrations/20230202105714_MigrationWallah2.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace EntityFrameworkLOL.Migrations -{ - /// - public partial class MigrationWallah2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Rune", - columns: table => new - { - Name = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Rune", x => x.Name); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Rune"); - } - } -} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs b/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs new file mode 100644 index 0000000..956d301 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs @@ -0,0 +1,81 @@ +// +using EntityFrameworkLOL.DBContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + [DbContext(typeof(SQLiteContext))] + [Migration("20230204102144_MigrationWallah3")] + partial class MigrationWallah3 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Champion"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Rune"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Skin"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs b/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs new file mode 100644 index 0000000..49e7a9d --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs @@ -0,0 +1,69 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + /// + public partial class MigrationWallah3 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Champion", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Bio = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Champion", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Rune", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Rune", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Skin", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Skin", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Champion"); + + migrationBuilder.DropTable( + name: "Rune"); + + migrationBuilder.DropTable( + name: "Skin"); + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs index 59fd766..963e51a 100644 --- a/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs +++ b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs @@ -16,19 +16,62 @@ namespace EntityFrameworkLOL.Migrations #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + b.Property("Name") + .IsRequired() .HasColumnType("TEXT"); + b.HasKey("Id"); + + b.ToTable("Champion"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + b.Property("Description") .IsRequired() .HasColumnType("TEXT"); - b.HasKey("Name"); + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); b.ToTable("Rune"); }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Skin"); + }); #pragma warning restore 612, 618 } } diff --git a/Sources/EntityFrameworkLOL/Program.cs b/Sources/EntityFrameworkLOL/Program.cs index e0798bd..70babcb 100644 --- a/Sources/EntityFrameworkLOL/Program.cs +++ b/Sources/EntityFrameworkLOL/Program.cs @@ -8,12 +8,12 @@ class Program { static void Main(string[] args) { - ChampionEntity akali = new ChampionEntity { Name = "Akali" }; - ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox" }; - ChampionEntity ahri = new ChampionEntity { Name = "Ahri" }; - ChampionEntity bard = new ChampionEntity { Name = "Bard" }; - ChampionEntity alistar = new ChampionEntity { Name = "Alistar" }; - ChampionEntity akshan = new ChampionEntity { Name = "Akshan" }; + /*ChampionEntity akali = new ChampionEntity { Id = 1, Name = "Akali", Bio = "" }; + ChampionEntity aatrox = new ChampionEntity { Id = 2, Name = "Aatrox", Bio = "" }; + ChampionEntity ahri = new ChampionEntity { Id = 3, Name = "Ahri", Bio = "" }; + ChampionEntity bard = new ChampionEntity { Id = 4, Name = "Bard", Bio = "" }; + ChampionEntity alistar = new ChampionEntity { Id = 5, Name = "Alistar", Bio = "" }; + ChampionEntity akshan = new ChampionEntity { Id = 6, Name = "Akshan", Bio = "" }; using (var context = new ChampionContext()) { @@ -30,15 +30,15 @@ class Program var aChampion = context.Champion .Where(c => c.Name.StartsWith("A")) .First(); - Console.WriteLine($"{aChampion.Name} (with bio : {aChampion.Bio}"); + Console.WriteLine($"{aChampion.Name} (with bio : \"{aChampion.Bio}\")"); } - RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" }; - RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" }; - RuneEntity alacrity = new RuneEntity { Name = "Legend : Alacrity", Description = "" }; - RuneEntity tenacity = new RuneEntity { Name = "Legend : Tenacity", Description = "" }; - RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" }; - RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" }; + RuneEntity conqueror = new RuneEntity { Id = 1, Name = "Conqueror", Description = "" }; + RuneEntity thriumph = new RuneEntity { Id = 2, Name = "Thriumph", Description = "" }; + RuneEntity alacrity = new RuneEntity { Id = 3, Name = "Legend : Alacrity", Description = "" }; + RuneEntity tenacity = new RuneEntity { Id = 4, Name = "Legend : Tenacity", Description = "" }; + RuneEntity laststand = new RuneEntity { Id = 5, Name = "Last Stand", Description = "" }; + RuneEntity laststand2 = new RuneEntity { Id = 6, Name = "Last Stand 2", Description = "" }; using (var context = new RuneContext()) { @@ -55,15 +55,15 @@ class Program var lRune = context.Rune .Where(r => r.Name.StartsWith("L")) .First(); - Console.WriteLine($"{lRune.Name} (with Description : {lRune.Description}"); + Console.WriteLine($"{lRune.Name} (with Description : \"{lRune.Description}\")"); } - SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" }; - SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" }; - SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" }; - SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" }; - SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" }; - SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" }; + SkinEntity stinger = new SkinEntity { Id = 1, Name = "Stinger", Description = "" }; + SkinEntity infernal = new SkinEntity { Id = 2, Name = "Infernal", Description = "" }; + SkinEntity allStar = new SkinEntity { Id = 3, Name = "All-Star", Description = "" }; + SkinEntity justicar = new SkinEntity { Id = 4, Name = "Justicar", Description = "" }; + SkinEntity mecha = new SkinEntity { Id = 5, Name = "Mecha", Description = "" }; + SkinEntity seaHunter = new SkinEntity { Id = 6, Name = "Sea Hunter", Description = "" }; using (var context = new SkinContext()) { @@ -80,18 +80,28 @@ class Program var iSkin = context.Skin .Where(s => s.Name.StartsWith("I")) .First(); - Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}"); + Console.WriteLine($"{iSkin.Name} (with Description : \"{iSkin.Description}\")"); Console.WriteLine("Updates the name of the Infernal Skin"); - iSkin.Name = "Infernal of Hell (Wallah)"; + iSkin.Description = "Hella Infernal (Wallah)"; context.SaveChanges(); - Console.WriteLine($"{iSkin.Name} (with Description : {iSkin.Description}"); + Console.WriteLine($"{iSkin.Name} (with Description : \"{iSkin.Description}\")"); Console.WriteLine("Deletes one item from the database"); var droid = context.Skin .SingleOrDefault(s => s.Name.Equals("Infernal")); context.Remove(droid); context.SaveChanges(); + }*/ + + using (var context = new ChampionContext()) + { + foreach (var c in context.Champion) + { + c.Bio = $"{c.Name}"; + Console.WriteLine($"{c.Name} - {c.Bio}"); + } + context.SaveChanges(); } } } \ No newline at end of file From 12b0acc1a967d87bd557d1f08715e1a0da0b9851 Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Wed, 8 Feb 2023 17:17:28 +0100 Subject: [PATCH 3/7] push Bdd (sauf dico et skill) --- .../DBContexts/SQLiteContext.cs | 9 +- Sources/EntityFrameworkLOL/DBLOL.db | Bin 45056 -> 98304 bytes .../Entities/CategoryEntity.cs | 24 ++ .../Entities/ChamionClassEntity.cs | 21 ++ .../Entities/ChampionEntity.cs | 20 +- .../Entities/ImageEntity.cs | 24 ++ .../EntityFrameworkLOL/Entities/RuneEntity.cs | 7 +- .../Entities/RuneFamilyEntity.cs | 21 ++ .../Entities/RunePageEntity.cs | 27 +++ .../Entities/SkillEntity.cs | 24 ++ .../Entities/SkillTypeEntity.cs | 19 ++ .../EntityFrameworkLOL/Entities/SkinEntity.cs | 11 +- .../EntityFrameworkLOL.csproj | 4 + ...0230204102144_MigrationWallah3.Designer.cs | 81 ------- .../20230204102144_MigrationWallah3.cs | 69 ------ ...0230208161248_MigrationWallah4.Designer.cs | 227 ++++++++++++++++++ .../20230208161248_MigrationWallah4.cs | 223 +++++++++++++++++ .../Migrations/SQLiteContextModelSnapshot.cs | 170 ++++++++++++- Sources/EntityFrameworkLOL/Program.cs | 38 +-- 19 files changed, 825 insertions(+), 194 deletions(-) create mode 100644 Sources/EntityFrameworkLOL/Entities/CategoryEntity.cs create mode 100644 Sources/EntityFrameworkLOL/Entities/ChamionClassEntity.cs create mode 100644 Sources/EntityFrameworkLOL/Entities/ImageEntity.cs create mode 100644 Sources/EntityFrameworkLOL/Entities/RuneFamilyEntity.cs create mode 100644 Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs create mode 100644 Sources/EntityFrameworkLOL/Entities/SkillEntity.cs create mode 100644 Sources/EntityFrameworkLOL/Entities/SkillTypeEntity.cs delete mode 100644 Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs delete mode 100644 Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.Designer.cs create mode 100644 Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.cs diff --git a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs index 511998a..dba6295 100644 --- a/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs +++ b/Sources/EntityFrameworkLOL/DBContexts/SQLiteContext.cs @@ -5,9 +5,16 @@ namespace EntityFrameworkLOL.DBContexts { class SQLiteContext : DbContext { - public DbSet Champion { get; set; } + public DbSet Category { get; set; } + public DbSet RuneFamily { get; set; } + public DbSet Image { get; set; } + public DbSet SkillType { get; set; } + //public DbSet Skill { get; set; } public DbSet Skin { get; set; } public DbSet Rune { get; set; } + public DbSet ChampionClass { get; set; } + public DbSet RunePage { get; set; } + public DbSet Champion { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder options) => options.UseSqlite($"Data Source=DBLOL.db"); diff --git a/Sources/EntityFrameworkLOL/DBLOL.db b/Sources/EntityFrameworkLOL/DBLOL.db index 858361157c2dffac2361045c41627337790772a0..b647dff5e791fe42309bf5c1dfefa58464f9ff91 100644 GIT binary patch literal 98304 zcmeI)O>Y~=8NhL_D3KB+?)oM4x&>UXS)dA&)aF|xr$&m(G?fyPDVbtY`;aoM#5zRu z;)rq)p90x!a_u4Qq2Hk>0u%w-Lx6sTo_Z*H$hjY&$Ik3>NX~LsUKcrd(Laqf_vM+L zXMZ!Z%Uu%MxwqLr={dhVIzH&0IF-b?gkdCp;y8&!Vp~j?#iU*>F*BpAp|7PCH&MtjnesA%c#nr_xGhfYrk@-#P>-mpn|D5{WY%}@K z^@fB#8i zPcB>v-n$CXcRgBLc=SrzzIDYo&8Z!$gPY7=t;-mH&$Pd4L- zS6+6Cywk4VZ#&H`F}=IF>D0EGJMGq5quF-y+Z%3I%{$wz#@)5n181ZD;EiF~JH5f~ zasSbY=wH5FsEEdH=%(%C{;sH5^!UwD&7)%DaiMlB@={xsmFm;eA(IEN?j1l!l^V^A zi?46B>Wz1r^3cSnQh}rG1(D=>y;X14>O0P8vutA*uQ1Fjs8V-?>itBoOdG;lJ?<7+ ziFba;7qXec@`aRrD`zC!emnShUtFO&-Nz?K?y`4EDao`iK6}k_d%|a{ZcmV7MNa4R zo*-9=8lv|EufYG-6V7bX(byE{zIOecdduG>e7G_ZkM&!^4Q@lX8u_1>UuT@A-io93 zdRG~jbWaF-`GP!s->Glb#Yw)lwo_ZXQgTKRVWNR74OsX`6OGsd|(JB78Zb`{f4M8S=sQXCCrw+3}0%{zM2 zsOt5WQTuSWhBwZ068JVpcVN%BVW#Zbm9X)y4x&?1bJnLzY5VF`HjFcF>^)y=yhDx4 zS$ns=)o6-3?$(=aHI!5Z{u7}%#KUyjwr%6|mYcBK``rKL^)%I$V|ZR4UO)7qN2#>EylgzJxD~2i<_;QdA+0B%ZF?~)U(tztg0+SNH~?#VHf6v5y79nGeR!=L z^ge#vJKXL07U#6|eH&jr6rYgZ5G4y{BQY;;F`jOm6y{U*+jiK%bTK<6_ie%Yk5}r` zId5d#^DMh3y@yA~Pin*Wl$JtXtsdiz*Z7as-<0FX2|dw!PVXCOdv(=#y5(lj>D1Tn z_8%U1<;S=I6?g9Zh7d#>DpV(ca_TllOYZgXzzj z;?Np1Df|7^u;vJ?r&9`CofPfsHgZIIvtQzPVbO zs=Dk|oz?=YrE1gPgwu5{%ZZ+I<}hDYgS4;0r=YdgZV47 zB{uOw009ILKmY**5I_I{1Q7VY6Zn2|!+6dEgsdJD`0QY5A|~vy!J-}$_{1RNiwSyI zurLu5_MBi|j|qH4kk(@YpAMvaF+mRo<|bo8o(atQVuBtABz-YKPXcDHB^wLF_6m6j zAn*UhkN)LL{?^}~nB?-Mi76-MWuzr087H@^NiJUy(|Iv1iHR2i2q1s}0tg_000Iag zfB*sryhH->_y6*)UVQ&A{=GzrkqQC`AbJ5009ILKmY** z5I_I{1Q2*}0q*}_+>8~h|HUnJ@(3 z-~UI1A`Afp5I_I{1Q0*~0R#|00D%|_@cn;`8;{fxKmY**5I_I{1Q0*~0R#|;D8T)H zL@2@#KmY**5I_I{1Q0*~0R#|;u>kk~F>X9kM*sl?5I_I{1Q0*~0R#|0Aff>G{}G`G zLjVB;5I_I{1Q0*~0R#|0AjSgR|HruTNF4zL5I_I{1Q0*~0R#|00D*`C-2X>}A`Afp V5I_I{1Q0*~0R#|00D%|_{1ERg6vxLqUhjuJ^EQFSY_2grGtK^-@|;T7ilO#41ln|nKO~rfY;;Z`xM@jXA0S5mO&8QLn6MW0pvFj{v)L4a84BgP% zdkPQoHU@leT9&d{iNuG#JJt{r0zguU! z$Su<}l|`?UTbuFN0dm7!7}hdov8XH_PTT=L1sQoqeMJr#Tcw`vlXYW*e5$UKBk8Q% znjWZN`Gw(hZ{E>X;Krtn9UXV3#_cI*bYk4z61(IkW3Mb_*vnPqGJDrvc!Op-6RoyS zCP{9!J5j!a@^7~ILXq{k{`OtIUm4K(2!Z?X9ee`EU>J1%h+p9s_%t7Bi`_PFk8HXb z2c03X0$1Tv2;m*r2^xki^UwGh40@l-YE^G9ROgiS41ORQoLAu+cm}`0=Wq+oW5_v} zD`+Yym7JN`h6q+qLsdz!I4Z*9v2jHurs>QG-|HN>UZccTBm2`TDVH7Jn~g-+y)ea~ zaRH|hda;!XsZIwGh0SwL=VVxf!U}=EfIfwlcHdj~;I%BJMJ3*omQCSTM|ne`mXZjk z#c3Ky0)N6|xC58rYmhj^-0Be9*o2sk>{=v(cGi2}wNy8F>zu{-N4a=~Uf+gf= z!5qG9vkn{zPPkzp{DZFV3p@FkSc0Z?U&q zvyoR9VXULY9N(|tP$3S_EtXW%k*UmTkrzz6VJr+O;9?Nz7q|=8;1XOyqK}d23EBQ; zl9b$b^MoD4{g0H_=vuKf?WN1Avh($ diff --git a/Sources/EntityFrameworkLOL/Entities/CategoryEntity.cs b/Sources/EntityFrameworkLOL/Entities/CategoryEntity.cs new file mode 100644 index 0000000..caa6ded --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/CategoryEntity.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.Xml.Linq; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; +using Model; +using static System.Net.Mime.MediaTypeNames; +using System.Reflection.PortableExecutable; +using System.Security.Claims; + +namespace EntityFrameworkLOL.Entities +{ + class CategoryEntity + { + [Key] + [ForeignKey("RunePageEntity")] + public RunePage.Category Category { get; set; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/ChamionClassEntity.cs b/Sources/EntityFrameworkLOL/Entities/ChamionClassEntity.cs new file mode 100644 index 0000000..8a75e0d --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/ChamionClassEntity.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using Model; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EntityFrameworkLOL.Entities +{ + class ChampionClassEntity + { + [Key] + [ForeignKey("ChampionEntity")] + public int Id { get; set; } + + public ChampionClass Class { get; set; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs b/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs index 925512a..dbf5173 100644 --- a/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs @@ -6,19 +6,31 @@ using System.Collections.Generic; using System.Text; using System.ComponentModel.DataAnnotations; using System.Xml.Linq; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; +using Model; +using static System.Net.Mime.MediaTypeNames; +using System.Reflection.PortableExecutable; +using System.Security.Claims; namespace EntityFrameworkLOL.Entities { class ChampionEntity { [Key] - public int Id { get; set; } - - [Required] public string Name { get; set; } public string Bio { get; set; } - /*public string Icon { get; set; }*/ + public string Icon { get; set; } + + [NotMapped] + public Dictionary Characteristics { get; set; } + + public ChampionClassEntity Class { get; set; } + + public ImageEntity Image { get; set; } + + //public ICollection Skills { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/ImageEntity.cs b/Sources/EntityFrameworkLOL/Entities/ImageEntity.cs new file mode 100644 index 0000000..07a6d91 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/ImageEntity.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.Xml.Linq; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; +using Model; +using static System.Net.Mime.MediaTypeNames; +using System.Reflection.PortableExecutable; +using System.Security.Claims; + +namespace EntityFrameworkLOL.Entities +{ + class ImageEntity + { + [Key] + [ForeignKey("ChampionEntity")] + public string Base64 { get; set; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs index 296a68a..f313cdf 100644 --- a/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/RuneEntity.cs @@ -11,11 +11,12 @@ namespace EntityFrameworkLOL.Entities class RuneEntity { [Key] - public int Id { get; set; } - - [Required] public string Name { get; set; } public string Description { get; set; } + + public ImageEntity Image { get; set; } + + public RuneFamilyEntity Family { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/RuneFamilyEntity.cs b/Sources/EntityFrameworkLOL/Entities/RuneFamilyEntity.cs new file mode 100644 index 0000000..c7369ad --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/RuneFamilyEntity.cs @@ -0,0 +1,21 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using Model; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EntityFrameworkLOL.Entities +{ + class RuneFamilyEntity + { + [Key] + [ForeignKey("RuneEntity")] + public int Id { get; set; } + + public RuneFamily Family { get; set; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs b/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs new file mode 100644 index 0000000..e99dd61 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/RunePageEntity.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.Xml.Linq; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations.Schema; +using Model; +using static System.Net.Mime.MediaTypeNames; +using System.Reflection.PortableExecutable; +using System.Security.Claims; + +namespace EntityFrameworkLOL.Entities +{ + class RunePageEntity + { + [Key] + public string Name { get; set; } + + [NotMapped] + public Dictionary Dictionary { get; set; } + // Switch Dictionary to List puis faudra juste mapper la liste en dico + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/SkillEntity.cs b/Sources/EntityFrameworkLOL/Entities/SkillEntity.cs new file mode 100644 index 0000000..dbefb19 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/SkillEntity.cs @@ -0,0 +1,24 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EntityFrameworkLOL.Entities +{ + class SkillEntity + { + [Key] + public string Name { get; set; } + + public string Description { get; set; } + + public SkillTypeEntity Type { get; set; } + + [NotMapped] + public ICollection Champions { get; set; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/SkillTypeEntity.cs b/Sources/EntityFrameworkLOL/Entities/SkillTypeEntity.cs new file mode 100644 index 0000000..b17df20 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Entities/SkillTypeEntity.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Linq; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel.DataAnnotations; +using Model; +using System.ComponentModel.DataAnnotations.Schema; + +namespace EntityFrameworkLOL.Entities +{ + class SkillTypeEntity + { + [Key] + [ForeignKey("SkillEntity")] + public SkillType Type { get; set; } + } +} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs b/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs index 67676c7..d14983b 100644 --- a/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/SkinEntity.cs @@ -11,15 +11,16 @@ namespace EntityFrameworkLOL.Entities class SkinEntity { [Key] - public int Id { get; set; } - - [Required] public string Name { get; set; } public string Description { get; set; } - /*public string Icon { get; set; } + public string Icon { get; set; } + + public float Price { get; set; } + + public ImageEntity Image { get; set; } - public float Price { get; set; }*/ + public ChampionEntity ChampionSkin { get; set; } } } \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj index bb493f8..9c01959 100644 --- a/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj +++ b/Sources/EntityFrameworkLOL/EntityFrameworkLOL.csproj @@ -25,4 +25,8 @@ + + + + \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs b/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs deleted file mode 100644 index 956d301..0000000 --- a/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.Designer.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -using EntityFrameworkLOL.DBContexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EntityFrameworkLOL.Migrations -{ - [DbContext(typeof(SQLiteContext))] - [Migration("20230204102144_MigrationWallah3")] - partial class MigrationWallah3 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Bio") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Champion"); - }); - - modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Rune"); - }); - - modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Skin"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs b/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs deleted file mode 100644 index 49e7a9d..0000000 --- a/Sources/EntityFrameworkLOL/Migrations/20230204102144_MigrationWallah3.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace EntityFrameworkLOL.Migrations -{ - /// - public partial class MigrationWallah3 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Champion", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", nullable: false), - Bio = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Champion", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Rune", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Rune", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Skin", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Skin", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Champion"); - - migrationBuilder.DropTable( - name: "Rune"); - - migrationBuilder.DropTable( - name: "Skin"); - } - } -} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.Designer.cs b/Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.Designer.cs new file mode 100644 index 0000000..e79b656 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.Designer.cs @@ -0,0 +1,227 @@ +// +using EntityFrameworkLOL.DBContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + [DbContext(typeof(SQLiteContext))] + [Migration("20230208161248_MigrationWallah4")] + partial class MigrationWallah4 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.CategoryEntity", b => + { + b.Property("Category") + .HasColumnType("INTEGER"); + + b.HasKey("Category"); + + b.ToTable("Category"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionClassEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Class") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("ChampionClass"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClassId") + .HasColumnType("INTEGER"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ImageBase64") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ClassId"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Champion"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b => + { + b.Property("Base64") + .HasColumnType("TEXT"); + + b.HasKey("Base64"); + + b.ToTable("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FamilyId") + .HasColumnType("INTEGER"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("FamilyId"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Rune"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneFamilyEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Family") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("RuneFamily"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("RunePage"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillTypeEntity", b => + { + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Type"); + + b.ToTable("SkillType"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ChampionSkinName") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionSkinName"); + + b.HasIndex("ImageBase64"); + + b.ToTable("Skin"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionClassEntity", "Class") + .WithMany() + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Class"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.RuneFamilyEntity", "Family") + .WithMany() + .HasForeignKey("FamilyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("Family"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin") + .WithMany() + .HasForeignKey("ChampionSkinName"); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("ChampionSkin"); + + b.Navigation("Image"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.cs b/Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.cs new file mode 100644 index 0000000..2f96331 --- /dev/null +++ b/Sources/EntityFrameworkLOL/Migrations/20230208161248_MigrationWallah4.cs @@ -0,0 +1,223 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFrameworkLOL.Migrations +{ + /// + public partial class MigrationWallah4 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Category", + columns: table => new + { + Category = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Category", x => x.Category); + }); + + migrationBuilder.CreateTable( + name: "ChampionClass", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Class = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampionClass", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Image", + columns: table => new + { + Base64 = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Image", x => x.Base64); + }); + + migrationBuilder.CreateTable( + name: "RuneFamily", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Family = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RuneFamily", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "RunePage", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RunePage", x => x.Name); + }); + + migrationBuilder.CreateTable( + name: "SkillType", + columns: table => new + { + Type = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SkillType", x => x.Type); + }); + + migrationBuilder.CreateTable( + name: "Champion", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Bio = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "TEXT", nullable: false), + ClassId = table.Column(type: "INTEGER", nullable: false), + ImageBase64 = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Champion", x => x.Name); + table.ForeignKey( + name: "FK_Champion_ChampionClass_ClassId", + column: x => x.ClassId, + principalTable: "ChampionClass", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Champion_Image_ImageBase64", + column: x => x.ImageBase64, + principalTable: "Image", + principalColumn: "Base64", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Rune", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false), + ImageBase64 = table.Column(type: "TEXT", nullable: true), + FamilyId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Rune", x => x.Name); + table.ForeignKey( + name: "FK_Rune_Image_ImageBase64", + column: x => x.ImageBase64, + principalTable: "Image", + principalColumn: "Base64"); + table.ForeignKey( + name: "FK_Rune_RuneFamily_FamilyId", + column: x => x.FamilyId, + principalTable: "RuneFamily", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Skin", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "TEXT", nullable: false), + Price = table.Column(type: "REAL", nullable: false), + ImageBase64 = table.Column(type: "TEXT", nullable: true), + ChampionSkinName = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Skin", x => x.Name); + table.ForeignKey( + name: "FK_Skin_Champion_ChampionSkinName", + column: x => x.ChampionSkinName, + principalTable: "Champion", + principalColumn: "Name"); + table.ForeignKey( + name: "FK_Skin_Image_ImageBase64", + column: x => x.ImageBase64, + principalTable: "Image", + principalColumn: "Base64"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Champion_ClassId", + table: "Champion", + column: "ClassId"); + + migrationBuilder.CreateIndex( + name: "IX_Champion_ImageBase64", + table: "Champion", + column: "ImageBase64"); + + migrationBuilder.CreateIndex( + name: "IX_Rune_FamilyId", + table: "Rune", + column: "FamilyId"); + + migrationBuilder.CreateIndex( + name: "IX_Rune_ImageBase64", + table: "Rune", + column: "ImageBase64"); + + migrationBuilder.CreateIndex( + name: "IX_Skin_ChampionSkinName", + table: "Skin", + column: "ChampionSkinName"); + + migrationBuilder.CreateIndex( + name: "IX_Skin_ImageBase64", + table: "Skin", + column: "ImageBase64"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Category"); + + migrationBuilder.DropTable( + name: "Rune"); + + migrationBuilder.DropTable( + name: "RunePage"); + + migrationBuilder.DropTable( + name: "SkillType"); + + migrationBuilder.DropTable( + name: "Skin"); + + migrationBuilder.DropTable( + name: "RuneFamily"); + + migrationBuilder.DropTable( + name: "Champion"); + + migrationBuilder.DropTable( + name: "ChampionClass"); + + migrationBuilder.DropTable( + name: "Image"); + } + } +} diff --git a/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs index 963e51a..85b39a6 100644 --- a/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs +++ b/Sources/EntityFrameworkLOL/Migrations/SQLiteContextModelSnapshot.cs @@ -16,62 +16,208 @@ namespace EntityFrameworkLOL.Migrations #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + modelBuilder.Entity("EntityFrameworkLOL.Entities.CategoryEntity", b => + { + b.Property("Category") + .HasColumnType("INTEGER"); + + b.HasKey("Category"); + + b.ToTable("Category"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionClassEntity", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); + b.Property("Class") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("ChampionClass"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + b.Property("Bio") .IsRequired() .HasColumnType("TEXT"); - b.Property("Name") + b.Property("ClassId") + .HasColumnType("INTEGER"); + + b.Property("Icon") .IsRequired() .HasColumnType("TEXT"); - b.HasKey("Id"); + b.Property("ImageBase64") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.HasIndex("ClassId"); + + b.HasIndex("ImageBase64"); b.ToTable("Champion"); }); + modelBuilder.Entity("EntityFrameworkLOL.Entities.ImageEntity", b => + { + b.Property("Base64") + .HasColumnType("TEXT"); + + b.HasKey("Base64"); + + b.ToTable("Image"); + }); + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + b.Property("Name") + .HasColumnType("TEXT"); b.Property("Description") .IsRequired() .HasColumnType("TEXT"); - b.Property("Name") - .IsRequired() + b.Property("FamilyId") + .HasColumnType("INTEGER"); + + b.Property("ImageBase64") .HasColumnType("TEXT"); - b.HasKey("Id"); + b.HasKey("Name"); + + b.HasIndex("FamilyId"); + + b.HasIndex("ImageBase64"); b.ToTable("Rune"); }); - modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneFamilyEntity", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); + b.Property("Family") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("RuneFamily"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RunePageEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("RunePage"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkillTypeEntity", b => + { + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Type"); + + b.ToTable("SkillType"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ChampionSkinName") + .HasColumnType("TEXT"); + b.Property("Description") .IsRequired() .HasColumnType("TEXT"); - b.Property("Name") + b.Property("Icon") .IsRequired() .HasColumnType("TEXT"); - b.HasKey("Id"); + b.Property("ImageBase64") + .HasColumnType("TEXT"); + + b.Property("Price") + .HasColumnType("REAL"); + + b.HasKey("Name"); + + b.HasIndex("ChampionSkinName"); + + b.HasIndex("ImageBase64"); b.ToTable("Skin"); }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.ChampionEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionClassEntity", "Class") + .WithMany() + .HasForeignKey("ClassId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Class"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.RuneEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.RuneFamilyEntity", "Family") + .WithMany() + .HasForeignKey("FamilyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("Family"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("EntityFrameworkLOL.Entities.SkinEntity", b => + { + b.HasOne("EntityFrameworkLOL.Entities.ChampionEntity", "ChampionSkin") + .WithMany() + .HasForeignKey("ChampionSkinName"); + + b.HasOne("EntityFrameworkLOL.Entities.ImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageBase64"); + + b.Navigation("ChampionSkin"); + + b.Navigation("Image"); + }); #pragma warning restore 612, 618 } } diff --git a/Sources/EntityFrameworkLOL/Program.cs b/Sources/EntityFrameworkLOL/Program.cs index 70babcb..3a99cee 100644 --- a/Sources/EntityFrameworkLOL/Program.cs +++ b/Sources/EntityFrameworkLOL/Program.cs @@ -8,12 +8,12 @@ class Program { static void Main(string[] args) { - /*ChampionEntity akali = new ChampionEntity { Id = 1, Name = "Akali", Bio = "" }; - ChampionEntity aatrox = new ChampionEntity { Id = 2, Name = "Aatrox", Bio = "" }; - ChampionEntity ahri = new ChampionEntity { Id = 3, Name = "Ahri", Bio = "" }; - ChampionEntity bard = new ChampionEntity { Id = 4, Name = "Bard", Bio = "" }; - ChampionEntity alistar = new ChampionEntity { Id = 5, Name = "Alistar", Bio = "" }; - ChampionEntity akshan = new ChampionEntity { Id = 6, Name = "Akshan", Bio = "" }; + ChampionEntity akali = new ChampionEntity { Name = "Akali", Bio = "" }; + ChampionEntity aatrox = new ChampionEntity { Name = "Aatrox", Bio = "" }; + ChampionEntity ahri = new ChampionEntity { Name = "Ahri", Bio = "" }; + ChampionEntity bard = new ChampionEntity { Name = "Bard", Bio = "" }; + ChampionEntity alistar = new ChampionEntity { Name = "Alistar", Bio = "" }; + ChampionEntity akshan = new ChampionEntity { Name = "Akshan", Bio = "" }; using (var context = new ChampionContext()) { @@ -33,12 +33,12 @@ class Program Console.WriteLine($"{aChampion.Name} (with bio : \"{aChampion.Bio}\")"); } - RuneEntity conqueror = new RuneEntity { Id = 1, Name = "Conqueror", Description = "" }; - RuneEntity thriumph = new RuneEntity { Id = 2, Name = "Thriumph", Description = "" }; - RuneEntity alacrity = new RuneEntity { Id = 3, Name = "Legend : Alacrity", Description = "" }; - RuneEntity tenacity = new RuneEntity { Id = 4, Name = "Legend : Tenacity", Description = "" }; - RuneEntity laststand = new RuneEntity { Id = 5, Name = "Last Stand", Description = "" }; - RuneEntity laststand2 = new RuneEntity { Id = 6, Name = "Last Stand 2", Description = "" }; + RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "" }; + RuneEntity thriumph = new RuneEntity { Name = "Thriumph", Description = "" }; + RuneEntity alacrity = new RuneEntity { Name = "Legend : Alacrity", Description = "" }; + RuneEntity tenacity = new RuneEntity { Name = "Legend : Tenacity", Description = "" }; + RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" }; + RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" }; using (var context = new RuneContext()) { @@ -58,12 +58,12 @@ class Program Console.WriteLine($"{lRune.Name} (with Description : \"{lRune.Description}\")"); } - SkinEntity stinger = new SkinEntity { Id = 1, Name = "Stinger", Description = "" }; - SkinEntity infernal = new SkinEntity { Id = 2, Name = "Infernal", Description = "" }; - SkinEntity allStar = new SkinEntity { Id = 3, Name = "All-Star", Description = "" }; - SkinEntity justicar = new SkinEntity { Id = 4, Name = "Justicar", Description = "" }; - SkinEntity mecha = new SkinEntity { Id = 5, Name = "Mecha", Description = "" }; - SkinEntity seaHunter = new SkinEntity { Id = 6, Name = "Sea Hunter", Description = "" }; + SkinEntity stinger = new SkinEntity { Name = "Stinger", Description = "" }; + SkinEntity infernal = new SkinEntity { Name = "Infernal", Description = "" }; + SkinEntity allStar = new SkinEntity { Name = "All-Star", Description = "" }; + SkinEntity justicar = new SkinEntity { Name = "Justicar", Description = "" }; + SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" }; + SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" }; using (var context = new SkinContext()) { @@ -92,7 +92,7 @@ class Program .SingleOrDefault(s => s.Name.Equals("Infernal")); context.Remove(droid); context.SaveChanges(); - }*/ + } using (var context = new ChampionContext()) { From b5d8d82ad7fcdbb4a87d4dfaa80412de2b0fe20f Mon Sep 17 00:00:00 2001 From: Louison PARANT Date: Wed, 8 Feb 2023 17:25:08 +0100 Subject: [PATCH 4/7] push bdd (v2 tjr pas dico ni skill) --- .../DBContexts/ChampionContext.cs | 13 ------------- .../EntityFrameworkLOL/DBContexts/RuneContext.cs | 13 ------------- .../EntityFrameworkLOL/DBContexts/SkinContext.cs | 13 ------------- .../EntityFrameworkLOL/Entities/ChampionEntity.cs | 1 + Sources/EntityFrameworkLOL/Program.cs | 8 ++++---- 5 files changed, 5 insertions(+), 43 deletions(-) delete mode 100644 Sources/EntityFrameworkLOL/DBContexts/ChampionContext.cs delete mode 100644 Sources/EntityFrameworkLOL/DBContexts/RuneContext.cs delete mode 100644 Sources/EntityFrameworkLOL/DBContexts/SkinContext.cs diff --git a/Sources/EntityFrameworkLOL/DBContexts/ChampionContext.cs b/Sources/EntityFrameworkLOL/DBContexts/ChampionContext.cs deleted file mode 100644 index f7d3a11..0000000 --- a/Sources/EntityFrameworkLOL/DBContexts/ChampionContext.cs +++ /dev/null @@ -1,13 +0,0 @@ -using EntityFrameworkLOL.Entities; -using Microsoft.EntityFrameworkCore; - -namespace EntityFrameworkLOL.DBContexts -{ - class ChampionContext : DbContext - { - public DbSet Champion { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder options) - => options.UseSqlite($"Data Source=DBLOL.db"); - } -} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBContexts/RuneContext.cs b/Sources/EntityFrameworkLOL/DBContexts/RuneContext.cs deleted file mode 100644 index daa69f9..0000000 --- a/Sources/EntityFrameworkLOL/DBContexts/RuneContext.cs +++ /dev/null @@ -1,13 +0,0 @@ -using EntityFrameworkLOL.Entities; -using Microsoft.EntityFrameworkCore; - -namespace EntityFrameworkLOL.DBContexts -{ - class RuneContext : DbContext - { - public DbSet Rune { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder options) - => options.UseSqlite($"Data Source=DBLOL.db"); - } -} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/DBContexts/SkinContext.cs b/Sources/EntityFrameworkLOL/DBContexts/SkinContext.cs deleted file mode 100644 index 5628c53..0000000 --- a/Sources/EntityFrameworkLOL/DBContexts/SkinContext.cs +++ /dev/null @@ -1,13 +0,0 @@ -using EntityFrameworkLOL.Entities; -using Microsoft.EntityFrameworkCore; - -namespace EntityFrameworkLOL.DBContexts -{ - class SkinContext : DbContext - { - public DbSet Skin { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder options) - => options.UseSqlite($"Data Source=DBLOL.db"); - } -} \ No newline at end of file diff --git a/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs b/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs index dbf5173..bfd6593 100644 --- a/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs +++ b/Sources/EntityFrameworkLOL/Entities/ChampionEntity.cs @@ -26,6 +26,7 @@ namespace EntityFrameworkLOL.Entities [NotMapped] public Dictionary Characteristics { get; set; } + // Switch Dictionary to List puis faudra juste mapper la liste en dico public ChampionClassEntity Class { get; set; } diff --git a/Sources/EntityFrameworkLOL/Program.cs b/Sources/EntityFrameworkLOL/Program.cs index 3a99cee..be3799b 100644 --- a/Sources/EntityFrameworkLOL/Program.cs +++ b/Sources/EntityFrameworkLOL/Program.cs @@ -15,7 +15,7 @@ class Program ChampionEntity alistar = new ChampionEntity { Name = "Alistar", Bio = "" }; ChampionEntity akshan = new ChampionEntity { Name = "Akshan", Bio = "" }; - using (var context = new ChampionContext()) + using (var context = new SQLiteContext()) { // Crée des champions et les insère dans la base Console.WriteLine("Creates and inserts new Champions"); @@ -40,7 +40,7 @@ class Program RuneEntity laststand = new RuneEntity { Name = "Last Stand", Description = "" }; RuneEntity laststand2 = new RuneEntity { Name = "Last Stand 2", Description = "" }; - using (var context = new RuneContext()) + using (var context = new SQLiteContext()) { // Crée des Runes et les insère dans la base Console.WriteLine("Creates and inserts new Runes"); @@ -65,7 +65,7 @@ class Program SkinEntity mecha = new SkinEntity { Name = "Mecha", Description = "" }; SkinEntity seaHunter = new SkinEntity { Name = "Sea Hunter", Description = "" }; - using (var context = new SkinContext()) + using (var context = new SQLiteContext()) { // Crée des Skins et les insère dans la base Console.WriteLine("Creates and inserts new Skins"); @@ -94,7 +94,7 @@ class Program context.SaveChanges(); } - using (var context = new ChampionContext()) + using (var context = new SQLiteContext()) { foreach (var c in context.Champion) { From 38afc66b3f268f2689a5a19128bd20c49a980635 Mon Sep 17 00:00:00 2001 From: Lucas DELANIER Date: Thu, 9 Feb 2023 13:45:50 +0100 Subject: [PATCH 5/7] Ajouter '.drone.yml' --- .drone.yml | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..08028fe --- /dev/null +++ b/.drone.yml @@ -0,0 +1,66 @@ +kind: pipeline +type: docker +name: default + +trigger: + event: + - push + +steps: + - name: build + image: mcr.microsoft.com/dotnet/sdk:6.0 + volumes: + - name: docs + path: /docs + commands: + - cd Sources/ + - dotnet restore Solution.sln + - dotnet build Solution.sln -c Release --no-restore + - dotnet publish Solution.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + + - name: tests + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: + - cd Sources/ + - dotnet restore Solution.sln + - dotnet test Solution.sln --no-restore + depends_on: [build] + + - name: code-analysis + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + commands: + - cd Sources/ + - dotnet restore Solution.sln + - dotnet sonarscanner begin /k:TEST /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN} + - dotnet build Solution.sln -c Release --no-restore + - dotnet test Solution.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + - dotnet publish Solution.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} + secrets: [ SECRET_SONAR_LOGIN ] + settings: + # accessible en ligne de commande par ${PLUGIN_SONAR_HOST} + sonar_host: https://codefirst.iut.uca.fr/sonar/ + # accessible en ligne de commande par ${PLUGIN_SONAR_TOKEN} + sonar_token: + from_secret: SECRET_SONAR_LOGIN + depends_on: [tests] + + - name: generate-and-deploy-docs + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer + failure: ignore + volumes: + - name: docs + path: /docs + commands: + #- cd Documentation/doxygen + #- doxygen Doxyfile + - /entrypoint.sh + when: + branch: + - master + depends_on: [ build ] + +volumes: +- name: docs + temp: {} \ No newline at end of file From 1b17d933622aa7086a3cc90c115ad246e69a974f Mon Sep 17 00:00:00 2001 From: Lucas DELANIER Date: Thu, 9 Feb 2023 13:47:50 +0100 Subject: [PATCH 6/7] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 08028fe..5ecbcb4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -63,4 +63,4 @@ steps: volumes: - name: docs - temp: {} \ No newline at end of file + temp: {} From 46e9f76669e9020e5e5b673e8951881ee41a37c2 Mon Sep 17 00:00:00 2001 From: Lucas DELANIER Date: Thu, 9 Feb 2023 13:50:08 +0100 Subject: [PATCH 7/7] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5ecbcb4..dd32bbc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,28 +14,28 @@ steps: path: /docs commands: - cd Sources/ - - dotnet restore Solution.sln - - dotnet build Solution.sln -c Release --no-restore - - dotnet publish Solution.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet restore LeagueOfLegends.sln + - dotnet build LeagueOfLegends.sln -c Release --no-restore + - dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - name: tests image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd Sources/ - - dotnet restore Solution.sln - - dotnet test Solution.sln --no-restore + - dotnet restore LeagueOfLegends.sln + - dotnet test LeagueOfLegends.sln --no-restore depends_on: [build] - name: code-analysis image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - cd Sources/ - - dotnet restore Solution.sln + - dotnet restore LeagueOfLegends.sln - dotnet sonarscanner begin /k:TEST /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - - dotnet build Solution.sln -c Release --no-restore - - dotnet test Solution.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - dotnet build LeagueOfLegends.sln -c Release --no-restore + - dotnet test LeagueOfLegends.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - dotnet publish Solution.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet publish LeagueOfLegends.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} secrets: [ SECRET_SONAR_LOGIN ] settings: