diff --git a/.vs/League-of-Legends_Project3/v17/.wsuo b/.vs/League-of-Legends_Project3/v17/.wsuo index e917b20..80c36fc 100644 Binary files a/.vs/League-of-Legends_Project3/v17/.wsuo and b/.vs/League-of-Legends_Project3/v17/.wsuo differ diff --git a/EntityFramework_LoL/Sources/Entities/ChampionDbContext.cs b/EntityFramework_LoL/Sources/Entities/ChampionDbContext.cs index b2c8f8f..e28b10f 100644 --- a/EntityFramework_LoL/Sources/Entities/ChampionDbContext.cs +++ b/EntityFramework_LoL/Sources/Entities/ChampionDbContext.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Shared; +using System.Reflection.Metadata; using System.Security.Claims; using System.Xml.Linq; @@ -12,6 +13,7 @@ namespace Entities public DbSet skills { get; set; } public DbSet runes { get; set; } public DbSet runepages { get; set; } + public DbSet largeimages { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -21,8 +23,24 @@ namespace Entities protected override void OnModelCreating(ModelBuilder modelBuilder) { + + modelBuilder.Entity().Property(e => e.Id).ValueGeneratedOnAdd(); + modelBuilder.Entity().Property(e => e.Id).ValueGeneratedOnAdd(); + modelBuilder.Entity() + .HasMany(x => x.runes) + .WithMany(x => x.runepages) + .UsingEntity(); + + modelBuilder.Entity().HasData(new List() + { + new() + { + Id = Guid.NewGuid(), + Base64 = "aaa" + } + }); modelBuilder.Entity().HasData(new List() { new() diff --git a/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs b/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs index eea4371..5e3101a 100644 --- a/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs +++ b/EntityFramework_LoL/Sources/Entities/ChampionEntity.cs @@ -15,8 +15,14 @@ namespace Entities public string? Icon { get; set; } [Required] public ChampionClass Class { get; set;} - public virtual ICollection? Skills { get; set; } + public Guid? ImageId { get; set; } + + [ForeignKey("ImageId")] + public LargeImageEntity? Image { get; set; } + + + } } diff --git a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db index 301c8f4..5847519 100644 Binary files a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db and b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db differ diff --git a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-shm b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-shm index 9cd8351..be1302a 100644 Binary files a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-shm and b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-shm differ diff --git a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-wal b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-wal index c02c794..d2719b5 100644 Binary files a/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-wal and b/EntityFramework_LoL/Sources/Entities/Entities.Champions.db-wal differ diff --git a/EntityFramework_LoL/Sources/Entities/LargeImageEntity.cs b/EntityFramework_LoL/Sources/Entities/LargeImageEntity.cs new file mode 100644 index 0000000..3448ac9 --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/LargeImageEntity.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entities +{ + public class LargeImageEntity + { + + [Key] + public Guid Id { get; set; } + [Required] + public string Base64 { get; set; } + + } +} diff --git a/EntityFramework_LoL/Sources/Entities/Migrations/20230208162909_myFirstMigration.Designer.cs b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.Designer.cs similarity index 78% rename from EntityFramework_LoL/Sources/Entities/Migrations/20230208162909_myFirstMigration.Designer.cs rename to EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.Designer.cs index 130ec85..81f4297 100644 --- a/EntityFramework_LoL/Sources/Entities/Migrations/20230208162909_myFirstMigration.Designer.cs +++ b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.Designer.cs @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Entities.Migrations { [DbContext(typeof(ChampionDbContext))] - [Migration("20230208162909_myFirstMigration")] + [Migration("20230209133904_myFirstMigration")] partial class myFirstMigration { /// @@ -52,8 +52,13 @@ namespace Entities.Migrations b.Property("Icon") .HasColumnType("TEXT"); + b.Property("ImageId") + .HasColumnType("TEXT"); + b.HasKey("Name"); + b.HasIndex("ImageId"); + b.ToTable("champions"); b.HasData( @@ -71,6 +76,28 @@ namespace Entities.Migrations }); }); + modelBuilder.Entity("Entities.LargeImageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Base64") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("largeimages"); + + b.HasData( + new + { + Id = new Guid("70d7aace-13a9-40e1-bd94-99790805f6d0"), + Base64 = "aaa" + }); + }); + modelBuilder.Entity("Entities.RuneEntity", b => { b.Property("Name") @@ -82,11 +109,16 @@ namespace Entities.Migrations .HasMaxLength(500) .HasColumnType("TEXT"); + b.Property("ImageId") + .HasColumnType("TEXT"); + b.Property("RuneFamily") .HasColumnType("INTEGER"); b.HasKey("Name"); + b.HasIndex("ImageId"); + b.ToTable("runes"); b.HasData( @@ -122,11 +154,29 @@ namespace Entities.Migrations b.HasData( new { - Id = new Guid("78729bae-c931-4a75-9662-6754ed8e2ce3"), + Id = new Guid("a5a4f69b-5cbb-48c1-beb4-896bc9171714"), Name = "Runepage_1" }); }); + modelBuilder.Entity("Entities.RunePageRuneEntity", b => + { + b.Property("runepagesId") + .HasColumnType("TEXT"); + + b.Property("runesName") + .HasColumnType("TEXT"); + + b.Property("Category") + .HasColumnType("INTEGER"); + + b.HasKey("runepagesId", "runesName"); + + b.HasIndex("runesName"); + + b.ToTable("RunePageRuneEntity"); + }); + modelBuilder.Entity("Entities.SkillEntity", b => { b.Property("Name") @@ -179,6 +229,9 @@ namespace Entities.Migrations .IsRequired() .HasColumnType("TEXT"); + b.Property("ImageId") + .HasColumnType("TEXT"); + b.Property("Price") .HasColumnType("REAL"); @@ -186,6 +239,8 @@ namespace Entities.Migrations b.HasIndex("ChampionForeignKey"); + b.HasIndex("ImageId"); + b.ToTable("skins"); b.HasData( @@ -207,21 +262,6 @@ namespace Entities.Migrations }); }); - modelBuilder.Entity("RuneEntityRunePageEntity", b => - { - b.Property("runepagesId") - .HasColumnType("TEXT"); - - b.Property("runesName") - .HasColumnType("TEXT"); - - b.HasKey("runepagesId", "runesName"); - - b.HasIndex("runesName"); - - b.ToTable("RuneEntityRunePageEntity"); - }); - modelBuilder.Entity("ChampionEntitySkillEntity", b => { b.HasOne("Entities.ChampionEntity", null) @@ -237,18 +277,25 @@ namespace Entities.Migrations .IsRequired(); }); - modelBuilder.Entity("Entities.SkinEntity", b => + modelBuilder.Entity("Entities.ChampionEntity", b => { - b.HasOne("Entities.ChampionEntity", "Champion") + b.HasOne("Entities.LargeImageEntity", "Image") .WithMany() - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("ImageId"); - b.Navigation("Champion"); + b.Navigation("Image"); }); - modelBuilder.Entity("RuneEntityRunePageEntity", b => + modelBuilder.Entity("Entities.RuneEntity", b => + { + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Entities.RunePageRuneEntity", b => { b.HasOne("Entities.RunePageEntity", null) .WithMany() @@ -262,6 +309,23 @@ namespace Entities.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); + + modelBuilder.Entity("Entities.SkinEntity", b => + { + b.HasOne("Entities.ChampionEntity", "Champion") + .WithMany() + .HasForeignKey("ChampionForeignKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Champion"); + + b.Navigation("Image"); + }); #pragma warning restore 612, 618 } } diff --git a/EntityFramework_LoL/Sources/Entities/Migrations/20230208162909_myFirstMigration.cs b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.cs similarity index 70% rename from EntityFramework_LoL/Sources/Entities/Migrations/20230208162909_myFirstMigration.cs rename to EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.cs index 62248a1..eb3748a 100644 --- a/EntityFramework_LoL/Sources/Entities/Migrations/20230208162909_myFirstMigration.cs +++ b/EntityFramework_LoL/Sources/Entities/Migrations/20230209133904_myFirstMigration.cs @@ -14,17 +14,15 @@ namespace Entities.Migrations protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "champions", + name: "largeimages", columns: table => new { - Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), - Bio = table.Column(type: "TEXT", maxLength: 500, nullable: false), - Icon = table.Column(type: "TEXT", nullable: true), - Class = table.Column(type: "INTEGER", nullable: false) + Id = table.Column(type: "TEXT", nullable: false), + Base64 = table.Column(type: "TEXT", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_champions", x => x.Name); + table.PrimaryKey("PK_largeimages", x => x.Id); }); migrationBuilder.CreateTable( @@ -40,29 +38,79 @@ namespace Entities.Migrations }); migrationBuilder.CreateTable( - name: "runes", + name: "skills", columns: table => new { Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), - RuneFamily = table.Column(type: "INTEGER", nullable: false) + SkillType = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_runes", x => x.Name); + table.PrimaryKey("PK_skills", x => x.Name); }); migrationBuilder.CreateTable( - name: "skills", + name: "champions", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Bio = table.Column(type: "TEXT", maxLength: 500, nullable: false), + Icon = table.Column(type: "TEXT", nullable: true), + Class = table.Column(type: "INTEGER", nullable: false), + ImageId = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_champions", x => x.Name); + table.ForeignKey( + name: "FK_champions_largeimages_ImageId", + column: x => x.ImageId, + principalTable: "largeimages", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "runes", columns: table => new { Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), - SkillType = table.Column(type: "INTEGER", nullable: false) + RuneFamily = table.Column(type: "INTEGER", nullable: false), + ImageId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_skills", x => x.Name); + table.PrimaryKey("PK_runes", x => x.Name); + table.ForeignKey( + name: "FK_runes_largeimages_ImageId", + column: x => x.ImageId, + principalTable: "largeimages", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "ChampionEntitySkillEntity", + columns: table => new + { + ChampionsName = table.Column(type: "TEXT", nullable: false), + SkillsName = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ChampionEntitySkillEntity", x => new { x.ChampionsName, x.SkillsName }); + table.ForeignKey( + name: "FK_ChampionEntitySkillEntity_champions_ChampionsName", + column: x => x.ChampionsName, + principalTable: "champions", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ChampionEntitySkillEntity_skills_SkillsName", + column: x => x.SkillsName, + principalTable: "skills", + principalColumn: "Name", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -73,7 +121,8 @@ namespace Entities.Migrations Description = table.Column(type: "TEXT", maxLength: 500, nullable: false), Icon = table.Column(type: "TEXT", nullable: false), Price = table.Column(type: "REAL", nullable: false), - ChampionForeignKey = table.Column(type: "TEXT", nullable: false) + ChampionForeignKey = table.Column(type: "TEXT", nullable: false), + ImageId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { @@ -84,77 +133,64 @@ namespace Entities.Migrations principalTable: "champions", principalColumn: "Name", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_skins_largeimages_ImageId", + column: x => x.ImageId, + principalTable: "largeimages", + principalColumn: "Id"); }); migrationBuilder.CreateTable( - name: "RuneEntityRunePageEntity", + name: "RunePageRuneEntity", columns: table => new { runepagesId = table.Column(type: "TEXT", nullable: false), - runesName = table.Column(type: "TEXT", nullable: false) + runesName = table.Column(type: "TEXT", nullable: false), + Category = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_RuneEntityRunePageEntity", x => new { x.runepagesId, x.runesName }); + table.PrimaryKey("PK_RunePageRuneEntity", x => new { x.runepagesId, x.runesName }); table.ForeignKey( - name: "FK_RuneEntityRunePageEntity_runepages_runepagesId", + name: "FK_RunePageRuneEntity_runepages_runepagesId", column: x => x.runepagesId, principalTable: "runepages", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_RuneEntityRunePageEntity_runes_runesName", + name: "FK_RunePageRuneEntity_runes_runesName", column: x => x.runesName, principalTable: "runes", principalColumn: "Name", onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "ChampionEntitySkillEntity", - columns: table => new - { - ChampionsName = table.Column(type: "TEXT", nullable: false), - SkillsName = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ChampionEntitySkillEntity", x => new { x.ChampionsName, x.SkillsName }); - table.ForeignKey( - name: "FK_ChampionEntitySkillEntity_champions_ChampionsName", - column: x => x.ChampionsName, - principalTable: "champions", - principalColumn: "Name", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ChampionEntitySkillEntity_skills_SkillsName", - column: x => x.SkillsName, - principalTable: "skills", - principalColumn: "Name", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.InsertData( table: "champions", - columns: new[] { "Name", "Bio", "Class", "Icon" }, + columns: new[] { "Name", "Bio", "Class", "Icon", "ImageId" }, values: new object[,] { - { "Armure", "Solide", 6, null }, - { "Dave", "Le meilleur Jazzman de France", 2, null } + { "Armure", "Solide", 6, null, null }, + { "Dave", "Le meilleur Jazzman de France", 2, null, null } }); + migrationBuilder.InsertData( + table: "largeimages", + columns: new[] { "Id", "Base64" }, + values: new object[] { new Guid("70d7aace-13a9-40e1-bd94-99790805f6d0"), "aaa" }); + migrationBuilder.InsertData( table: "runepages", columns: new[] { "Id", "Name" }, - values: new object[] { new Guid("78729bae-c931-4a75-9662-6754ed8e2ce3"), "Runepage_1" }); + values: new object[] { new Guid("a5a4f69b-5cbb-48c1-beb4-896bc9171714"), "Runepage_1" }); migrationBuilder.InsertData( table: "runes", - columns: new[] { "Name", "Description", "RuneFamily" }, + columns: new[] { "Name", "Description", "ImageId", "RuneFamily" }, values: new object[,] { - { "Alkatraz", "Lock effect", 2 }, - { "Bullseye", "Steady shot", 1 } + { "Alkatraz", "Lock effect", null, 2 }, + { "Bullseye", "Steady shot", null, 1 } }); migrationBuilder.InsertData( @@ -168,11 +204,11 @@ namespace Entities.Migrations migrationBuilder.InsertData( table: "skins", - columns: new[] { "Name", "ChampionForeignKey", "Description", "Icon", "Price" }, + columns: new[] { "Name", "ChampionForeignKey", "Description", "Icon", "ImageId", "Price" }, values: new object[,] { - { "Armure Fullspeed", "Armure", "Deja vu", "aaa", 9.99f }, - { "Dave de glace", "Dave", "Enneigé", "aaa", 7.99f } + { "Armure Fullspeed", "Armure", "Deja vu", "aaa", null, 9.99f }, + { "Dave de glace", "Dave", "Enneigé", "aaa", null, 7.99f } }); migrationBuilder.CreateIndex( @@ -181,14 +217,29 @@ namespace Entities.Migrations column: "SkillsName"); migrationBuilder.CreateIndex( - name: "IX_RuneEntityRunePageEntity_runesName", - table: "RuneEntityRunePageEntity", + name: "IX_champions_ImageId", + table: "champions", + column: "ImageId"); + + migrationBuilder.CreateIndex( + name: "IX_RunePageRuneEntity_runesName", + table: "RunePageRuneEntity", column: "runesName"); + migrationBuilder.CreateIndex( + name: "IX_runes_ImageId", + table: "runes", + column: "ImageId"); + migrationBuilder.CreateIndex( name: "IX_skins_ChampionForeignKey", table: "skins", column: "ChampionForeignKey"); + + migrationBuilder.CreateIndex( + name: "IX_skins_ImageId", + table: "skins", + column: "ImageId"); } /// @@ -198,7 +249,7 @@ namespace Entities.Migrations name: "ChampionEntitySkillEntity"); migrationBuilder.DropTable( - name: "RuneEntityRunePageEntity"); + name: "RunePageRuneEntity"); migrationBuilder.DropTable( name: "skins"); @@ -214,6 +265,9 @@ namespace Entities.Migrations migrationBuilder.DropTable( name: "champions"); + + migrationBuilder.DropTable( + name: "largeimages"); } } } diff --git a/EntityFramework_LoL/Sources/Entities/Migrations/ChampionDbContextModelSnapshot.cs b/EntityFramework_LoL/Sources/Entities/Migrations/ChampionDbContextModelSnapshot.cs index 7679554..aef1440 100644 --- a/EntityFramework_LoL/Sources/Entities/Migrations/ChampionDbContextModelSnapshot.cs +++ b/EntityFramework_LoL/Sources/Entities/Migrations/ChampionDbContextModelSnapshot.cs @@ -49,8 +49,13 @@ namespace Entities.Migrations b.Property("Icon") .HasColumnType("TEXT"); + b.Property("ImageId") + .HasColumnType("TEXT"); + b.HasKey("Name"); + b.HasIndex("ImageId"); + b.ToTable("champions"); b.HasData( @@ -68,6 +73,28 @@ namespace Entities.Migrations }); }); + modelBuilder.Entity("Entities.LargeImageEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Base64") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("largeimages"); + + b.HasData( + new + { + Id = new Guid("70d7aace-13a9-40e1-bd94-99790805f6d0"), + Base64 = "aaa" + }); + }); + modelBuilder.Entity("Entities.RuneEntity", b => { b.Property("Name") @@ -79,11 +106,16 @@ namespace Entities.Migrations .HasMaxLength(500) .HasColumnType("TEXT"); + b.Property("ImageId") + .HasColumnType("TEXT"); + b.Property("RuneFamily") .HasColumnType("INTEGER"); b.HasKey("Name"); + b.HasIndex("ImageId"); + b.ToTable("runes"); b.HasData( @@ -119,11 +151,29 @@ namespace Entities.Migrations b.HasData( new { - Id = new Guid("78729bae-c931-4a75-9662-6754ed8e2ce3"), + Id = new Guid("a5a4f69b-5cbb-48c1-beb4-896bc9171714"), Name = "Runepage_1" }); }); + modelBuilder.Entity("Entities.RunePageRuneEntity", b => + { + b.Property("runepagesId") + .HasColumnType("TEXT"); + + b.Property("runesName") + .HasColumnType("TEXT"); + + b.Property("Category") + .HasColumnType("INTEGER"); + + b.HasKey("runepagesId", "runesName"); + + b.HasIndex("runesName"); + + b.ToTable("RunePageRuneEntity"); + }); + modelBuilder.Entity("Entities.SkillEntity", b => { b.Property("Name") @@ -176,6 +226,9 @@ namespace Entities.Migrations .IsRequired() .HasColumnType("TEXT"); + b.Property("ImageId") + .HasColumnType("TEXT"); + b.Property("Price") .HasColumnType("REAL"); @@ -183,6 +236,8 @@ namespace Entities.Migrations b.HasIndex("ChampionForeignKey"); + b.HasIndex("ImageId"); + b.ToTable("skins"); b.HasData( @@ -204,21 +259,6 @@ namespace Entities.Migrations }); }); - modelBuilder.Entity("RuneEntityRunePageEntity", b => - { - b.Property("runepagesId") - .HasColumnType("TEXT"); - - b.Property("runesName") - .HasColumnType("TEXT"); - - b.HasKey("runepagesId", "runesName"); - - b.HasIndex("runesName"); - - b.ToTable("RuneEntityRunePageEntity"); - }); - modelBuilder.Entity("ChampionEntitySkillEntity", b => { b.HasOne("Entities.ChampionEntity", null) @@ -234,18 +274,25 @@ namespace Entities.Migrations .IsRequired(); }); - modelBuilder.Entity("Entities.SkinEntity", b => + modelBuilder.Entity("Entities.ChampionEntity", b => { - b.HasOne("Entities.ChampionEntity", "Champion") + b.HasOne("Entities.LargeImageEntity", "Image") .WithMany() - .HasForeignKey("ChampionForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("ImageId"); - b.Navigation("Champion"); + b.Navigation("Image"); }); - modelBuilder.Entity("RuneEntityRunePageEntity", b => + modelBuilder.Entity("Entities.RuneEntity", b => + { + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Image"); + }); + + modelBuilder.Entity("Entities.RunePageRuneEntity", b => { b.HasOne("Entities.RunePageEntity", null) .WithMany() @@ -259,6 +306,23 @@ namespace Entities.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); + + modelBuilder.Entity("Entities.SkinEntity", b => + { + b.HasOne("Entities.ChampionEntity", "Champion") + .WithMany() + .HasForeignKey("ChampionForeignKey") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.LargeImageEntity", "Image") + .WithMany() + .HasForeignKey("ImageId"); + + b.Navigation("Champion"); + + b.Navigation("Image"); + }); #pragma warning restore 612, 618 } } diff --git a/EntityFramework_LoL/Sources/Entities/RuneEntity.cs b/EntityFramework_LoL/Sources/Entities/RuneEntity.cs index a89d1a4..9b1d077 100644 --- a/EntityFramework_LoL/Sources/Entities/RuneEntity.cs +++ b/EntityFramework_LoL/Sources/Entities/RuneEntity.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -20,8 +21,12 @@ namespace Entities [Required] public RuneFamily RuneFamily { get; set; } - public ICollection runepages { get; set; } + public ICollection? runepages { get; set; } + public Guid? ImageId { get; set; } + + [ForeignKey("ImageId")] + public LargeImageEntity? Image { get; set; } } } diff --git a/EntityFramework_LoL/Sources/Entities/RunePageRuneEntity.cs b/EntityFramework_LoL/Sources/Entities/RunePageRuneEntity.cs new file mode 100644 index 0000000..a1ad83f --- /dev/null +++ b/EntityFramework_LoL/Sources/Entities/RunePageRuneEntity.cs @@ -0,0 +1,14 @@ +using Shared; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entities +{ + public class RunePageRuneEntity + { + public Category Category { get; set; } + } +} diff --git a/EntityFramework_LoL/Sources/Entities/SkinEntity.cs b/EntityFramework_LoL/Sources/Entities/SkinEntity.cs index 0baace0..927dca3 100644 --- a/EntityFramework_LoL/Sources/Entities/SkinEntity.cs +++ b/EntityFramework_LoL/Sources/Entities/SkinEntity.cs @@ -28,5 +28,10 @@ namespace Entities [ForeignKey("ChampionForeignKey")] public ChampionEntity Champion { get; set; } + public Guid? ImageId { get; set; } + + [ForeignKey("ImageId")] + public LargeImageEntity? Image { get; set; } + } } diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.Designer.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.Designer.cs new file mode 100644 index 0000000..b64a1d8 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.Designer.cs @@ -0,0 +1,44 @@ +// +using EntityFramework.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFramework.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + [Migration("20230209124258_myFirstMigration")] + partial class myFirstMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.cs new file mode 100644 index 0000000..9f3f929 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230209124258_myFirstMigration.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFramework.Migrations +{ + /// + public partial class myFirstMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs b/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs index a08a947..169a102 100644 --- a/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs +++ b/EntityFramework_LoL/Sources/StubLib/StubData.RunePages.cs @@ -1,5 +1,6 @@ using System; using Model; +using Shared; namespace StubLib { @@ -10,12 +11,12 @@ namespace StubLib private void InitRunePages() { var runePage1 = new RunePage("rune page 1"); - runePage1[RunePage.Category.Major] = runes[0]; - runePage1[RunePage.Category.Minor1] = runes[1]; - runePage1[RunePage.Category.Minor2] = runes[2]; - runePage1[RunePage.Category.Minor3] = runes[3]; - runePage1[RunePage.Category.OtherMinor1] = runes[4]; - runePage1[RunePage.Category.OtherMinor2] = runes[5]; + runePage1[Category.Major] = runes[0]; + runePage1[Category.Minor1] = runes[1]; + runePage1[Category.Minor2] = runes[2]; + runePage1[Category.Minor3] = runes[3]; + runePage1[Category.OtherMinor1] = runes[4]; + runePage1[Category.OtherMinor2] = runes[5]; runePages.Add(runePage1); }