From 5423d0f282aa5ac7e337bd5a42549dc2670493d6 Mon Sep 17 00:00:00 2001 From: Pierre Ferreira Date: Mon, 13 Mar 2023 18:31:57 +0100 Subject: [PATCH] tentative de resolution du probleme de migration (coco a toi) :bug: --- Sources/EF_UT/EntityTest.cs | 12 +- Sources/EntityFramework/LoLDbContext.cs | 2 +- .../EntityFramework/Mapper/ChampionMapper.cs | 2 +- .../20230312170120_stubMig.Designer.cs | 83 --------- .../Migrations/20230312170120_stubMig.cs | 49 ------ .../Migrations/20230313155631_MyMigr.cs | 110 ------------ .../LoLDBContextWithStubModelSnapshot.cs | 80 --------- .../Stubbed/20230313160034_MyMigr.Designer.cs | 161 ------------------ .../Stubbed/20230313160034_MyMigr.cs | 121 ------------- .../Stubbed/StubbedContextModelSnapshot.cs | 158 ----------------- Sources/EntityFramework/Program.cs | 2 +- Sources/EntityFramework/StubbedContext.cs | 26 +-- Sources/EntityFramework/champion.db | 0 13 files changed, 22 insertions(+), 784 deletions(-) delete mode 100644 Sources/EntityFramework/Migrations/20230312170120_stubMig.Designer.cs delete mode 100644 Sources/EntityFramework/Migrations/20230312170120_stubMig.cs delete mode 100644 Sources/EntityFramework/Migrations/20230313155631_MyMigr.cs delete mode 100644 Sources/EntityFramework/Migrations/LoLDBContextWithStubModelSnapshot.cs delete mode 100644 Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.Designer.cs delete mode 100644 Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.cs delete mode 100644 Sources/EntityFramework/Migrations/Stubbed/StubbedContextModelSnapshot.cs create mode 100644 Sources/EntityFramework/champion.db diff --git a/Sources/EF_UT/EntityTest.cs b/Sources/EF_UT/EntityTest.cs index bd0005b..5fd0afb 100644 --- a/Sources/EF_UT/EntityTest.cs +++ b/Sources/EF_UT/EntityTest.cs @@ -23,9 +23,9 @@ namespace EF_UT using (var context = new LoLDbContext(options)) { - ChampionEntity chewie = new ChampionEntity("Chewbacca", "", ""); - ChampionEntity yoda = new ChampionEntity("Yoda", "", ""); - ChampionEntity ewok = new ChampionEntity("Ewok", "", ""); + ChampionEntity chewie = new ChampionEntity { Name = "Chewbacca", Bio = "", Icon = "" }; + ChampionEntity yoda = new ChampionEntity{ Name = "Yoda", Bio = "", Icon = "" }; + ChampionEntity ewok = new ChampionEntity{ Name = "Ewok", Bio = "", Icon = "" }; //SkinEntity defaulSkin = new SkinEntity("Skin Default", chewie); //chewie.AddSkin(defaulSkin); @@ -55,9 +55,9 @@ namespace EF_UT //prepares the database with one instance of the context using (var context = new LoLDbContext(options)) { - ChampionEntity chewie = new ChampionEntity("Chewbacca", "ewa", ""); - ChampionEntity yoda = new ChampionEntity("Yoda", "wewo", ""); - ChampionEntity ewok = new ChampionEntity("Ewok", "", ""); + ChampionEntity chewie = new ChampionEntity{ Name = "Chewbacca", Bio = "ewa", Icon = "" }; + ChampionEntity yoda = new ChampionEntity{ Name = "Yoda", Bio = "wewo", Icon = "" }; + ChampionEntity ewok = new ChampionEntity{ Name = "Ewok", Bio = "", Icon = "" }; context.Add(chewie); context.Add(yoda); diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs index 9bbf417..af9be3b 100644 --- a/Sources/EntityFramework/LoLDbContext.cs +++ b/Sources/EntityFramework/LoLDbContext.cs @@ -63,7 +63,7 @@ namespace EntityFramework // Add the shadow property to the model modelBuilder.Entity() - .Property("ChampionEntityForeignKey"); + .Property("ChampionEntityForeignKey"); // Use the shadow property as a foreign key modelBuilder.Entity() diff --git a/Sources/EntityFramework/Mapper/ChampionMapper.cs b/Sources/EntityFramework/Mapper/ChampionMapper.cs index 862264d..14942d1 100644 --- a/Sources/EntityFramework/Mapper/ChampionMapper.cs +++ b/Sources/EntityFramework/Mapper/ChampionMapper.cs @@ -10,7 +10,7 @@ namespace EntityFramework.Mapper public static class ChampionMapper { public static ChampionEntity ToEntity(this Champion champion) { - return new ChampionEntity(champion.Name, champion.Bio, champion.Icon); + return new ChampionEntity { Name = champion.Name, Bio = champion.Bio, Icon = champion.Icon }; } } } diff --git a/Sources/EntityFramework/Migrations/20230312170120_stubMig.Designer.cs b/Sources/EntityFramework/Migrations/20230312170120_stubMig.Designer.cs deleted file mode 100644 index 2b24874..0000000 --- a/Sources/EntityFramework/Migrations/20230312170120_stubMig.Designer.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -using EntityFramework; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EntityFramework.Migrations -{ - [DbContext(typeof(LoLDBContextWithStub))] - [Migration("20230312170120_stubMig")] - partial class stubMig - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFramework.ChampionEntity", b => - { - b.Property("Name") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Bio") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("string") - .HasColumnName("Bio"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Name"); - - b.ToTable("Champion", (string)null); - - b.HasData( - new - { - Name = "Akali", - Bio = "", - Icon = "" - }, - new - { - Name = "Aatrox", - Bio = "", - Icon = "" - }, - new - { - Name = "Ahri", - Bio = "", - Icon = "" - }, - new - { - Name = "Akshan", - Bio = "", - Icon = "" - }, - new - { - Name = "Bard", - Bio = "", - Icon = "" - }, - new - { - Name = "Alistar", - Bio = "", - Icon = "" - }); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/EntityFramework/Migrations/20230312170120_stubMig.cs b/Sources/EntityFramework/Migrations/20230312170120_stubMig.cs deleted file mode 100644 index 3323fa4..0000000 --- a/Sources/EntityFramework/Migrations/20230312170120_stubMig.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace EntityFramework.Migrations -{ - /// - public partial class stubMig : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Champion", - columns: table => new - { - Name = table.Column(type: "TEXT", maxLength: 50, nullable: false), - Bio = table.Column(type: "string", maxLength: 500, nullable: false), - Icon = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Champion", x => x.Name); - }); - - migrationBuilder.InsertData( - table: "Champion", - columns: new[] { "Name", "Bio", "Icon" }, - values: new object[,] - { - { "Aatrox", "", "" }, - { "Ahri", "", "" }, - { "Akali", "", "" }, - { "Akshan", "", "" }, - { "Alistar", "", "" }, - { "Bard", "", "" } - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Champion"); - } - } -} diff --git a/Sources/EntityFramework/Migrations/20230313155631_MyMigr.cs b/Sources/EntityFramework/Migrations/20230313155631_MyMigr.cs deleted file mode 100644 index 913356a..0000000 --- a/Sources/EntityFramework/Migrations/20230313155631_MyMigr.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace EntityFramework.Migrations -{ - /// - public partial class MyMigr : 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", maxLength: 50, nullable: false), - Bio = table.Column(type: "string", maxLength: 500, nullable: false), - Icon = table.Column(type: "TEXT", nullable: false), - Image = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Champion", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Image", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Base64 = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Image", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "SkillEntity", - columns: table => new - { - Name = table.Column(type: "TEXT", nullable: false), - Type = table.Column(type: "INTEGER", nullable: false), - Description = table.Column(type: "TEXT", nullable: false), - ChampionEntityId = table.Column(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SkillEntity", x => x.Name); - table.ForeignKey( - name: "FK_SkillEntity_Champion_ChampionEntityId", - column: x => x.ChampionEntityId, - principalTable: "Champion", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "Skins", - columns: table => new - { - Name = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", nullable: true), - Icon = table.Column(type: "TEXT", nullable: false), - Image = table.Column(type: "TEXT", nullable: true), - Price = table.Column(type: "REAL", nullable: false), - ChampionEntityForeignKey = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Skins", x => x.Name); - table.ForeignKey( - name: "FK_Skins_Champion_ChampionEntityForeignKey", - column: x => x.ChampionEntityForeignKey, - principalTable: "Champion", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_SkillEntity_ChampionEntityId", - table: "SkillEntity", - column: "ChampionEntityId"); - - migrationBuilder.CreateIndex( - name: "IX_Skins_ChampionEntityForeignKey", - table: "Skins", - column: "ChampionEntityForeignKey"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Image"); - - migrationBuilder.DropTable( - name: "SkillEntity"); - - migrationBuilder.DropTable( - name: "Skins"); - - migrationBuilder.DropTable( - name: "Champion"); - } - } -} diff --git a/Sources/EntityFramework/Migrations/LoLDBContextWithStubModelSnapshot.cs b/Sources/EntityFramework/Migrations/LoLDBContextWithStubModelSnapshot.cs deleted file mode 100644 index ba61c51..0000000 --- a/Sources/EntityFramework/Migrations/LoLDBContextWithStubModelSnapshot.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -using EntityFramework; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EntityFramework.Migrations -{ - [DbContext(typeof(LoLDBContextWithStub))] - partial class LoLDBContextWithStubModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFramework.ChampionEntity", b => - { - b.Property("Name") - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.Property("Bio") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("string") - .HasColumnName("Bio"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Name"); - - b.ToTable("Champion", (string)null); - - b.HasData( - new - { - Name = "Akali", - Bio = "", - Icon = "" - }, - new - { - Name = "Aatrox", - Bio = "", - Icon = "" - }, - new - { - Name = "Ahri", - Bio = "", - Icon = "" - }, - new - { - Name = "Akshan", - Bio = "", - Icon = "" - }, - new - { - Name = "Bard", - Bio = "", - Icon = "" - }, - new - { - Name = "Alistar", - Bio = "", - Icon = "" - }); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.Designer.cs b/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.Designer.cs deleted file mode 100644 index 5fdbb12..0000000 --- a/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.Designer.cs +++ /dev/null @@ -1,161 +0,0 @@ -// -using System; -using EntityFramework; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EntityFramework.Migrations.Stubbed -{ - [DbContext(typeof(StubbedContext))] - [Migration("20230313160034_MyMigr")] - partial class MyMigr - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFramework.ChampionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Bio") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("string") - .HasColumnName("Bio"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Champion", (string)null); - - b.HasData( - new - { - Id = 1673124670, - Bio = "biobiobiobio", - Icon = "/a/a/a/a", - Name = "Corichard" - }, - new - { - Id = -96935452, - Bio = "mimimimimim", - Icon = "/small.png", - Name = "Pintrand" - }); - }); - - modelBuilder.Entity("EntityFramework.LargeImageEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Base64") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Image"); - }); - - modelBuilder.Entity("EntityFramework.SkillEntity", b => - { - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("ChampionEntityId") - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("Name"); - - b.HasIndex("ChampionEntityId"); - - b.ToTable("SkillEntity"); - }); - - modelBuilder.Entity("EntityFramework.SkinEntity", b => - { - b.Property("Name") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("ChampionEntityForeignKey") - .HasColumnType("INTEGER"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.HasKey("Name"); - - b.HasIndex("ChampionEntityForeignKey"); - - b.ToTable("Skins"); - }); - - modelBuilder.Entity("EntityFramework.SkillEntity", b => - { - b.HasOne("EntityFramework.ChampionEntity", null) - .WithMany("Skills") - .HasForeignKey("ChampionEntityId"); - }); - - modelBuilder.Entity("EntityFramework.SkinEntity", b => - { - b.HasOne("EntityFramework.ChampionEntity", "Champion") - .WithMany("skins") - .HasForeignKey("ChampionEntityForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - }); - - modelBuilder.Entity("EntityFramework.ChampionEntity", b => - { - b.Navigation("Skills"); - - b.Navigation("skins"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.cs b/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.cs deleted file mode 100644 index a7f4acb..0000000 --- a/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.cs +++ /dev/null @@ -1,121 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace EntityFramework.Migrations.Stubbed -{ - /// - public partial class MyMigr : 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", maxLength: 50, nullable: false), - Bio = table.Column(type: "string", maxLength: 500, nullable: false), - Icon = table.Column(type: "TEXT", nullable: false), - Image = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Champion", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Image", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Base64 = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Image", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "SkillEntity", - columns: table => new - { - Name = table.Column(type: "TEXT", nullable: false), - Type = table.Column(type: "INTEGER", nullable: false), - Description = table.Column(type: "TEXT", nullable: false), - ChampionEntityId = table.Column(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_SkillEntity", x => x.Name); - table.ForeignKey( - name: "FK_SkillEntity_Champion_ChampionEntityId", - column: x => x.ChampionEntityId, - principalTable: "Champion", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "Skins", - columns: table => new - { - Name = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", nullable: true), - Icon = table.Column(type: "TEXT", nullable: false), - Image = table.Column(type: "TEXT", nullable: true), - Price = table.Column(type: "REAL", nullable: false), - ChampionEntityForeignKey = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Skins", x => x.Name); - table.ForeignKey( - name: "FK_Skins_Champion_ChampionEntityForeignKey", - column: x => x.ChampionEntityForeignKey, - principalTable: "Champion", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "Champion", - columns: new[] { "Id", "Bio", "Icon", "Image", "Name" }, - values: new object[,] - { - { -96935452, "mimimimimim", "/small.png", null, "Pintrand" }, - { 1673124670, "biobiobiobio", "/a/a/a/a", null, "Corichard" } - }); - - migrationBuilder.CreateIndex( - name: "IX_SkillEntity_ChampionEntityId", - table: "SkillEntity", - column: "ChampionEntityId"); - - migrationBuilder.CreateIndex( - name: "IX_Skins_ChampionEntityForeignKey", - table: "Skins", - column: "ChampionEntityForeignKey"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Image"); - - migrationBuilder.DropTable( - name: "SkillEntity"); - - migrationBuilder.DropTable( - name: "Skins"); - - migrationBuilder.DropTable( - name: "Champion"); - } - } -} diff --git a/Sources/EntityFramework/Migrations/Stubbed/StubbedContextModelSnapshot.cs b/Sources/EntityFramework/Migrations/Stubbed/StubbedContextModelSnapshot.cs deleted file mode 100644 index 3181e7d..0000000 --- a/Sources/EntityFramework/Migrations/Stubbed/StubbedContextModelSnapshot.cs +++ /dev/null @@ -1,158 +0,0 @@ -// -using System; -using EntityFramework; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace EntityFramework.Migrations.Stubbed -{ - [DbContext(typeof(StubbedContext))] - partial class StubbedContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("EntityFramework.ChampionEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Bio") - .IsRequired() - .HasMaxLength(500) - .HasColumnType("string") - .HasColumnName("Bio"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Champion", (string)null); - - b.HasData( - new - { - Id = 1673124670, - Bio = "biobiobiobio", - Icon = "/a/a/a/a", - Name = "Corichard" - }, - new - { - Id = -96935452, - Bio = "mimimimimim", - Icon = "/small.png", - Name = "Pintrand" - }); - }); - - modelBuilder.Entity("EntityFramework.LargeImageEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Base64") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Image"); - }); - - modelBuilder.Entity("EntityFramework.SkillEntity", b => - { - b.Property("Name") - .HasColumnType("TEXT"); - - b.Property("ChampionEntityId") - .HasColumnType("INTEGER"); - - b.Property("Description") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Type") - .HasColumnType("INTEGER"); - - b.HasKey("Name"); - - b.HasIndex("ChampionEntityId"); - - b.ToTable("SkillEntity"); - }); - - modelBuilder.Entity("EntityFramework.SkinEntity", b => - { - b.Property("Name") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("ChampionEntityForeignKey") - .HasColumnType("INTEGER"); - - b.Property("Description") - .HasColumnType("TEXT"); - - b.Property("Icon") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Image") - .HasColumnType("TEXT"); - - b.Property("Price") - .HasColumnType("REAL"); - - b.HasKey("Name"); - - b.HasIndex("ChampionEntityForeignKey"); - - b.ToTable("Skins"); - }); - - modelBuilder.Entity("EntityFramework.SkillEntity", b => - { - b.HasOne("EntityFramework.ChampionEntity", null) - .WithMany("Skills") - .HasForeignKey("ChampionEntityId"); - }); - - modelBuilder.Entity("EntityFramework.SkinEntity", b => - { - b.HasOne("EntityFramework.ChampionEntity", "Champion") - .WithMany("skins") - .HasForeignKey("ChampionEntityForeignKey") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Champion"); - }); - - modelBuilder.Entity("EntityFramework.ChampionEntity", b => - { - b.Navigation("Skills"); - - b.Navigation("skins"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Sources/EntityFramework/Program.cs b/Sources/EntityFramework/Program.cs index b06d523..a0c478c 100644 --- a/Sources/EntityFramework/Program.cs +++ b/Sources/EntityFramework/Program.cs @@ -40,7 +40,7 @@ using ( var context = new LoLDbContext()) Console.WriteLine("Champions : "); foreach (var champi in context.Champions.Include(a => a.skins)) { - Console.WriteLine($"\t{champi.Id}: {champi.Name} : {champi.Bio}"); + Console.WriteLine($"\t{champi.Name} : {champi.Bio}"); foreach (var s in champi.skins) { Console.WriteLine($"\t\t{s.Name}"); diff --git a/Sources/EntityFramework/StubbedContext.cs b/Sources/EntityFramework/StubbedContext.cs index 47aa944..833f0c7 100644 --- a/Sources/EntityFramework/StubbedContext.cs +++ b/Sources/EntityFramework/StubbedContext.cs @@ -18,25 +18,25 @@ namespace EntityFramework { base.OnModelCreating(modelBuilder); - ChampionEntity corichard = new ChampionEntity {Id=1, Name="Corichard", Bio="biobiobiobio", Icon="/a/a/a/a"}; - ChampionEntity pintrand = new ChampionEntity {Id=2, Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png" }; + ChampionEntity corichard = new ChampionEntity {Name="Corichard", Bio="biobiobiobio", Icon="/a/a/a/a"}; + ChampionEntity pintrand = new ChampionEntity {Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png" }; //ChampionEntity corichard = new ChampionEntity() { Name = "Corichard", Bio = "biobiobiobio", Icon = "/a/a/a/a", Image = new LargeImageEntity { Base64 = "base" } }; //ChampionEntity pintrand = new ChampionEntity { Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png", Image = new LargeImageEntity { Base64 = "base" } }; modelBuilder.Entity().HasData(corichard, pintrand); - modelBuilder.Entity().HasData(new { Name = "aaaa", ChampionEntityForeignKey = 1, Description = "So What", Icon="/Icon.png", Price=10.0f }, - new { Name = "skin", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "bo", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "Joulie", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "Radiance", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "void", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "Radiance", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "void", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "DarkTheme", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "gold", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0f }, - new { Name = "ruby", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0f } + modelBuilder.Entity().HasData(new { Name = "aaaa", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon="/Icon.png", Price=10.0f }, + new { Name = "skin", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "bo", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "Joulie", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "Radiance", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "void", ChampionEntityForeignKey = "Corichard", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "Radiance", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "void", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "DarkTheme", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "gold", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f }, + new { Name = "ruby", ChampionEntityForeignKey = "Pintrand", Description = "So What", Icon = "/Icon.png", Price = 10.0f } ); } diff --git a/Sources/EntityFramework/champion.db b/Sources/EntityFramework/champion.db new file mode 100644 index 0000000..e69de29