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 8583611..b647dff 100644 Binary files a/Sources/EntityFrameworkLOL/DBLOL.db and b/Sources/EntityFrameworkLOL/DBLOL.db differ 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()) {