From e3a9577eaa15d9c6632f9f76f97d250bb09a59bc Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Wed, 1 Mar 2023 17:35:56 +0100
Subject: [PATCH 1/7] =?UTF-8?q?:sparkles:=20Ajout=20de=20la=20class=20Skin?=
=?UTF-8?q?=20et=20cr=C3=A9ation=20de=20la=20branche?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Sources/EntityFramework/ChampionEntity.cs | 15 +++++
Sources/EntityFramework/LargeImageEntity.cs | 18 ++++++
Sources/EntityFramework/SkinEntity.cs | 68 +++++++++++++++++++++
3 files changed, 101 insertions(+)
create mode 100644 Sources/EntityFramework/LargeImageEntity.cs
create mode 100644 Sources/EntityFramework/SkinEntity.cs
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index 5d2c455..bc8de94 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -34,11 +34,15 @@ namespace EntityFramework
private ICollection Skills { get; set; }
+ public ReadOnlyCollection Skins { get; private set; }
+ private List skins = new();
+
public ChampionEntity(string name,string bio,string icon) {
this.Name = name;
this.Bio = bio;
this.Icon = icon;
Skills= new List();
+ Skins = new ReadOnlyCollection(skins);
}
public override string ToString()
@@ -53,5 +57,16 @@ namespace EntityFramework
public void RemoveSkill(SkillEntity skill)
=> Skills.Remove(skill);
+
+
+ public bool AddSkin(SkinEntity skin)
+ {
+ if (skins.Contains(skin))
+ return false;
+ skins.Add(skin);
+ return true;
+ }
+
+
}
}
diff --git a/Sources/EntityFramework/LargeImageEntity.cs b/Sources/EntityFramework/LargeImageEntity.cs
new file mode 100644
index 0000000..a1f8ae1
--- /dev/null
+++ b/Sources/EntityFramework/LargeImageEntity.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public class LargeImageEntity
+ {
+ public string Base64 { get; set; }
+
+ public LargeImageEntity(string base64)
+ {
+ Base64 = base64;
+ }
+ }
+}
diff --git a/Sources/EntityFramework/SkinEntity.cs b/Sources/EntityFramework/SkinEntity.cs
new file mode 100644
index 0000000..a71c5ea
--- /dev/null
+++ b/Sources/EntityFramework/SkinEntity.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public class SkinEntity //ON TO MANY
+ {
+ public string Name
+ {
+ get => name;
+ private init
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException("A skin must have a name");
+ }
+ name = value;
+ }
+ }
+ private readonly string name = null!;
+
+ public string Description
+ {
+ get => description;
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ description = "";
+ return;
+ }
+ description = value;
+ }
+ }
+ private string description = "";
+
+ public string Icon { get; set; }
+ public LargeImageEntity Image { get; set; }
+
+ public float Price { get; set; }
+
+ public ChampionEntity Champion
+ {
+ get => champion;
+ private init
+ {
+ if (value == null)
+ throw new ArgumentNullException("A skill can't have a null champion");
+ champion = value;
+ }
+ }
+ private readonly ChampionEntity champion = null!;
+
+ public SkinEntity(string name, ChampionEntity champion, float price = 0.0f, string icon = "", string image = "", string description = "")
+ {
+ Name = name;
+ Champion = champion;
+ Champion.AddSkin(this);
+ Price = price;
+ Icon = icon;
+ Image = new LargeImageEntity(image);
+ Description = description;
+ }
+ }
+}
From c72adccc1ad4e4d33984bf6814291c88650539dc Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Fri, 3 Mar 2023 14:47:06 +0100
Subject: [PATCH 2/7] tentative de reglage du probleme des tests suite a
l'ajout des skin, voir pour le One to Many ??
---
Sources/EF_UT/EntityTest.cs | 3 ++-
Sources/EntityFramework/ChampionEntity.cs | 3 +++
Sources/EntityFramework/SkinEntity.cs | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Sources/EF_UT/EntityTest.cs b/Sources/EF_UT/EntityTest.cs
index d1f87b5..f162b09 100644
--- a/Sources/EF_UT/EntityTest.cs
+++ b/Sources/EF_UT/EntityTest.cs
@@ -27,7 +27,8 @@ namespace EF_UT
ChampionEntity yoda = new ChampionEntity("Yoda", "", "");
ChampionEntity ewok = new ChampionEntity("Ewok", "", "");
-
+ //SkinEntity defaulSkin = new SkinEntity("Skin Default", chewie);
+ //chewie.AddSkin(defaulSkin);
Console.WriteLine("Creates and inserts new Champion for tests");
context.Add(chewie);
context.Add(yoda);
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index bc8de94..8822711 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -37,6 +37,9 @@ namespace EntityFramework
public ReadOnlyCollection Skins { get; private set; }
private List skins = new();
+ public LargeImageEntity Image { get; set; }
+
+
public ChampionEntity(string name,string bio,string icon) {
this.Name = name;
this.Bio = bio;
diff --git a/Sources/EntityFramework/SkinEntity.cs b/Sources/EntityFramework/SkinEntity.cs
index a71c5ea..adcf35c 100644
--- a/Sources/EntityFramework/SkinEntity.cs
+++ b/Sources/EntityFramework/SkinEntity.cs
@@ -58,7 +58,7 @@ namespace EntityFramework
{
Name = name;
Champion = champion;
- Champion.AddSkin(this);
+ //Champion.AddSkin(this);
Price = price;
Icon = icon;
Image = new LargeImageEntity(image);
From 11137d89aaae25fad50356141257f38e7385b108 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sat, 11 Mar 2023 11:39:21 +0100
Subject: [PATCH 3/7] =?UTF-8?q?:package:=20Cr=C3=A9ation=20du=20OneToMany?=
=?UTF-8?q?=20mais=20probleme=20dans=20la=20cr=C3=A9ation=20de=20la=20migr?=
=?UTF-8?q?ation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Sources/EntityFramework/ChampionEntity.cs | 31 +++---
Sources/EntityFramework/LargeImageEntity.cs | 14 ++-
Sources/EntityFramework/LoLDbContext.cs | 22 +++-
Sources/EntityFramework/Program.cs | 49 ++++++++-
Sources/EntityFramework/SkinEntity.cs | 105 +++++++++++---------
Sources/EntityFramework/StubbedContext.cs | 36 +++++++
6 files changed, 186 insertions(+), 71 deletions(-)
create mode 100644 Sources/EntityFramework/StubbedContext.cs
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index 8822711..8452958 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -15,7 +15,7 @@ namespace EntityFramework
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int Id { get; set; }
+ public int Id { get; set; } = Guid.NewGuid().GetHashCode();
[Required]
[MaxLength(50)]
@@ -32,21 +32,28 @@ namespace EntityFramework
//public ImmutableHashSet Skills => skills.ToImmutableHashSet();
//private HashSet skills = new HashSet();
- private ICollection Skills { get; set; }
+ public ICollection Skills { get; set; }
- public ReadOnlyCollection Skins { get; private set; }
- private List skins = new();
+ //public ReadOnlyCollection Skins { get; private set; }
+ //private List skins = new();
- public LargeImageEntity Image { get; set; }
+ public ICollection skins { get; set; }
+ public LargeImageEntity Image { get; set; } = new LargeImageEntity();
- public ChampionEntity(string name,string bio,string icon) {
- this.Name = name;
- this.Bio = bio;
- this.Icon = icon;
- Skills= new List();
- Skins = new ReadOnlyCollection(skins);
- }
+
+
+ ///
+ /// pas besoin de constructeur ! (sans lui, il est possible d'utiliser la syntaxe utilisé dans le stubbedbDBCOntext)
+ ///
+ ///
+ //public ChampionEntity(string name,string bio,string icon) {
+ // this.Name = name;
+ // this.Bio = bio;
+ // this.Icon = icon;
+ // Skills= new List();
+ // //Skins = new ReadOnlyCollection(skins);
+ //}
public override string ToString()
{
diff --git a/Sources/EntityFramework/LargeImageEntity.cs b/Sources/EntityFramework/LargeImageEntity.cs
index a1f8ae1..f86eade 100644
--- a/Sources/EntityFramework/LargeImageEntity.cs
+++ b/Sources/EntityFramework/LargeImageEntity.cs
@@ -1,18 +1,22 @@
-using System;
+using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramework
{
+
public class LargeImageEntity
{
+ [Key]
public string Base64 { get; set; }
- public LargeImageEntity(string base64)
- {
- Base64 = base64;
- }
+ //public LargeImageEntity(string base64)
+ //{
+ // Base64 = base64;
+ //}
}
}
diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs
index 9fa1567..7c8ea74 100644
--- a/Sources/EntityFramework/LoLDbContext.cs
+++ b/Sources/EntityFramework/LoLDbContext.cs
@@ -11,6 +11,8 @@ namespace EntityFramework
{
public DbSet Champions { get; set; }
+ public DbSet Skins { get; set; }
+
public LoLDbContext()
{ }
@@ -46,7 +48,25 @@ namespace EntityFramework
modelBuilder.Entity().Property(entity => entity.Icon)
.IsRequired();
-
+
+
+
+ /// One to many
+ /// ChampionEntity 1 ---> * SkinEntity
+ //création de la table Skin
+ modelBuilder.Entity().HasKey(skin => skin.Name); //définition de la clé primaire
+ modelBuilder.Entity().Property(skin => skin.Name)
+ .ValueGeneratedOnAdd(); //définition du mode de génération de la clé : génération à l'insertion
+
+ // Add the shadow property to the model
+ modelBuilder.Entity()
+ .Property("ChampionEntityForeignKey");
+
+ // Use the shadow property as a foreign key
+ modelBuilder.Entity()
+ .HasOne(skin => skin.Champion)
+ .WithMany(champion => champion.skins)
+ .HasForeignKey("ChampionEntityForeignKey");
}
}
diff --git a/Sources/EntityFramework/Program.cs b/Sources/EntityFramework/Program.cs
index 65ef614..b06d523 100644
--- a/Sources/EntityFramework/Program.cs
+++ b/Sources/EntityFramework/Program.cs
@@ -1,9 +1,10 @@
// See https://aka.ms/new-console-template for more information
using EntityFramework;
+using Microsoft.EntityFrameworkCore;
-using( var context = new LoLDbContext())
+using ( var context = new LoLDbContext())
{
- context.Add(new ChampionEntity("test","test","test") );
+ context.Add(new ChampionEntity{ Name = "test", Bio = "test", Icon = "test" } );
context.SaveChanges();
ChampionEntity champ = context.Find(1);
@@ -20,7 +21,7 @@ using( var context = new LoLDbContext())
}
//Test BDD Skills
- ChampionEntity champSkill = new ChampionEntity("nomSkill", "bioSkill", "iconSkill");
+ ChampionEntity champSkill = new ChampionEntity { Name="nomSkill", Bio="bioSkill", Icon="iconSkill" };
SkillEntity s1 = new SkillEntity("Skill1", "desc", SkillType.Unknown);
SkillEntity s2 = new SkillEntity("Skill2", "desc2", SkillType.Ultimate);
@@ -31,7 +32,47 @@ using( var context = new LoLDbContext())
champSkill.AddSkill(s3);
context.Add(champSkill);
-
+
context.SaveChanges();
+
+ //OneToMany
+ Console.WriteLine("Champions : ");
+ foreach (var champi in context.Champions.Include(a => a.skins))
+ {
+ Console.WriteLine($"\t{champi.Id}: {champi.Name} : {champi.Bio}");
+ foreach (var s in champi.skins)
+ {
+ Console.WriteLine($"\t\t{s.Name}");
+ }
+ }
+
+ Console.WriteLine();
+
+ Console.WriteLine("Skin :");
+ foreach (var s in context.Skins)
+ {
+ Console.WriteLine($"\t{s.Name}: {s.Description} (Champion : {s.Champion.Name})");
+ }
+
+
+ Console.WriteLine("\nAjout d'un Champion et 6 Skins...\n");
+
+ ChampionEntity captainMarvel = new ChampionEntity { Name = "Captain Marvel", Bio="Mais que fait un avenger ici ??", Icon="Icon.png"};
+ SkinEntity[] skins = { new SkinEntity {Name = "La Fiesta", Champion = captainMarvel},
+ new SkinEntity { Name = "Five Hundred Miles High", Champion = captainMarvel },
+ new SkinEntity { Name = "Captain Marvel", Champion = captainMarvel },
+ new SkinEntity { Name = "Time's Lie", Champion = captainMarvel },
+ new SkinEntity { Name = "Lush Life", Champion = captainMarvel },
+ new SkinEntity { Name = "Day Waves", Champion = captainMarvel }
+ };
+ foreach (var s in skins)
+ {
+ captainMarvel.skins.Add(s);
+ }
+
+ context.Add(captainMarvel);
+ context.SaveChanges();
+
+
}
diff --git a/Sources/EntityFramework/SkinEntity.cs b/Sources/EntityFramework/SkinEntity.cs
index adcf35c..6035674 100644
--- a/Sources/EntityFramework/SkinEntity.cs
+++ b/Sources/EntityFramework/SkinEntity.cs
@@ -6,63 +6,70 @@ using System.Threading.Tasks;
namespace EntityFramework
{
- public class SkinEntity //ON TO MANY
+ public class SkinEntity //ONE TO MANY
{
- public string Name
- {
- get => name;
- private init
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- throw new ArgumentException("A skin must have a name");
- }
- name = value;
- }
- }
- private readonly string name = null!;
- public string Description
- {
- get => description;
- set
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- description = "";
- return;
- }
- description = value;
- }
- }
- private string description = "";
+ public string? Name { get; set; }
+
+ public string? Description { get; set; }
+
+ //public string Name
+ //{
+ // get => name;
+ // private init
+ // {
+ // if (string.IsNullOrWhiteSpace(value))
+ // {
+ // throw new ArgumentException("A skin must have a name");
+ // }
+ // name = value;
+ // }
+ //}
+ //private readonly string name = null!;
+
+ //public string Description
+ //{
+ // get => description;
+ // set
+ // {
+ // if (string.IsNullOrWhiteSpace(value))
+ // {
+ // description = "";
+ // return;
+ // }
+ // description = value;
+ // }
+ //}
+ //private string description = "";
public string Icon { get; set; }
public LargeImageEntity Image { get; set; }
public float Price { get; set; }
+ public ChampionEntity Champion { get; set; }
+
- public ChampionEntity Champion
- {
- get => champion;
- private init
- {
- if (value == null)
- throw new ArgumentNullException("A skill can't have a null champion");
- champion = value;
- }
- }
- private readonly ChampionEntity champion = null!;
+ //public ChampionEntity Champion
+ //{
+ // get => champion;
+ // private init
+ // {
+ // if (value == null)
+ // throw new ArgumentNullException("A skill can't have a null champion");
+ // champion = value;
+ // }
+ //}
+ //private readonly ChampionEntity champion = null!;
- public SkinEntity(string name, ChampionEntity champion, float price = 0.0f, string icon = "", string image = "", string description = "")
- {
- Name = name;
- Champion = champion;
- //Champion.AddSkin(this);
- Price = price;
- Icon = icon;
- Image = new LargeImageEntity(image);
- Description = description;
- }
+ //public SkinEntity(string name, ChampionEntity champion, float price = 0.0f, string icon = "", string image = "", string description = "")
+ //{
+ // Name = name;
+ // Champion = champion;
+ // //Champion.AddSkin(this);
+ // Price = price;
+ // Icon = icon;
+ // Image = new LargeImageEntity(image);
+ // Description = description;
+ //}
}
}
diff --git a/Sources/EntityFramework/StubbedContext.cs b/Sources/EntityFramework/StubbedContext.cs
new file mode 100644
index 0000000..53efd24
--- /dev/null
+++ b/Sources/EntityFramework/StubbedContext.cs
@@ -0,0 +1,36 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public class StubbedContext : LoLDbContext
+ {
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ ChampionEntity corichard = new ChampionEntity() {Name="Corichard", Bio="biobiobiobio", Icon="/a/a/a/a"};
+ ChampionEntity pintrand = new ChampionEntity { Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png" };
+
+ modelBuilder.Entity().HasData(corichard, pintrand);
+
+ modelBuilder.Entity().HasData(new { Name = "aaaa", ChampionEntityForeignKey = 1, Description = "So What", Icon="/Icon.png", Price=10.0 },
+ new { Name = "skin", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "bo", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "Joulie", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "Radiance", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "void", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "Radiance", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "void", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "DarkTheme", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "gold", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
+ new { Name = "ruby", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 }
+ );
+ }
+
+ }
+}
From 10d4be1b54b2fe01a85a0d049b5225320f5bfe4b Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Sat, 11 Mar 2023 12:05:44 +0100
Subject: [PATCH 4/7] =?UTF-8?q?continuation=20de=20la=20recherche=20du=20p?=
=?UTF-8?q?robleme=20:=20seed,=20apparament=20li=C3=A9=20a=20des=20conflit?=
=?UTF-8?q?s=20de=20OneToMany?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Sources/EntityFramework/ChampionEntity.cs | 3 +-
.../EntityFramework/EntityFramework.csproj | 4 +
Sources/EntityFramework/LargeImageEntity.cs | 2 +-
Sources/EntityFramework/LoLDbContext.cs | 3 +
.../20230301152530_SkillMigration.Designer.cs | 85 ------------------
.../20230301152530_SkillMigration.cs | 63 -------------
.../Migrations/LoLDbContextModelSnapshot.cs | 82 -----------------
Sources/EntityFramework/SkinEntity.cs | 6 +-
Sources/EntityFramework/StubbedContext.cs | 32 ++++---
Sources/EntityFramework/champion.db | Bin 32768 -> 32768 bytes
10 files changed, 35 insertions(+), 245 deletions(-)
delete mode 100644 Sources/EntityFramework/Migrations/20230301152530_SkillMigration.Designer.cs
delete mode 100644 Sources/EntityFramework/Migrations/20230301152530_SkillMigration.cs
delete mode 100644 Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index 8452958..8a975d2 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -39,7 +39,8 @@ namespace EntityFramework
public ICollection skins { get; set; }
- public LargeImageEntity Image { get; set; } = new LargeImageEntity();
+ //public LargeImageEntity? Image { get; set; } ====> voir pour faire "plus propre" => créé une table pour l'entity Largeimage
+ public string? Image { get; set; }
diff --git a/Sources/EntityFramework/EntityFramework.csproj b/Sources/EntityFramework/EntityFramework.csproj
index 66899d0..6ca2f66 100644
--- a/Sources/EntityFramework/EntityFramework.csproj
+++ b/Sources/EntityFramework/EntityFramework.csproj
@@ -17,4 +17,8 @@
+
+
+
+
diff --git a/Sources/EntityFramework/LargeImageEntity.cs b/Sources/EntityFramework/LargeImageEntity.cs
index f86eade..b925a83 100644
--- a/Sources/EntityFramework/LargeImageEntity.cs
+++ b/Sources/EntityFramework/LargeImageEntity.cs
@@ -11,7 +11,7 @@ namespace EntityFramework
public class LargeImageEntity
{
- [Key]
+ public int Id { get; set; }
public string Base64 { get; set; }
//public LargeImageEntity(string base64)
diff --git a/Sources/EntityFramework/LoLDbContext.cs b/Sources/EntityFramework/LoLDbContext.cs
index 7c8ea74..91b440a 100644
--- a/Sources/EntityFramework/LoLDbContext.cs
+++ b/Sources/EntityFramework/LoLDbContext.cs
@@ -13,6 +13,9 @@ namespace EntityFramework
public DbSet Skins { get; set; }
+ public DbSet Image { get; set; }
+
+
public LoLDbContext()
{ }
diff --git a/Sources/EntityFramework/Migrations/20230301152530_SkillMigration.Designer.cs b/Sources/EntityFramework/Migrations/20230301152530_SkillMigration.Designer.cs
deleted file mode 100644
index 94bb55c..0000000
--- a/Sources/EntityFramework/Migrations/20230301152530_SkillMigration.Designer.cs
+++ /dev/null
@@ -1,85 +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
-{
- [DbContext(typeof(LoLDbContext))]
- [Migration("20230301152530_SkillMigration")]
- partial class SkillMigration
- {
- ///
- 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("Name")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Champion", (string)null);
- });
-
- modelBuilder.Entity("EntityFramework.Skill", 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("Skill");
- });
-
- modelBuilder.Entity("EntityFramework.Skill", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", null)
- .WithMany("Skills")
- .HasForeignKey("ChampionEntityId");
- });
-
- modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
- {
- b.Navigation("Skills");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Sources/EntityFramework/Migrations/20230301152530_SkillMigration.cs b/Sources/EntityFramework/Migrations/20230301152530_SkillMigration.cs
deleted file mode 100644
index ce0154c..0000000
--- a/Sources/EntityFramework/Migrations/20230301152530_SkillMigration.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace EntityFramework.Migrations
-{
- ///
- public partial class SkillMigration : 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)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Champion", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Skill",
- 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_Skill", x => x.Name);
- table.ForeignKey(
- name: "FK_Skill_Champion_ChampionEntityId",
- column: x => x.ChampionEntityId,
- principalTable: "Champion",
- principalColumn: "Id");
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_Skill_ChampionEntityId",
- table: "Skill",
- column: "ChampionEntityId");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Skill");
-
- migrationBuilder.DropTable(
- name: "Champion");
- }
- }
-}
diff --git a/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
deleted file mode 100644
index 0abeee1..0000000
--- a/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-using System;
-using EntityFramework;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EntityFramework.Migrations
-{
- [DbContext(typeof(LoLDbContext))]
- partial class LoLDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
-
- modelBuilder.Entity("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("Name")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Champion", (string)null);
- });
-
- modelBuilder.Entity("EntityFramework.Skill", 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("Skill");
- });
-
- modelBuilder.Entity("EntityFramework.Skill", b =>
- {
- b.HasOne("EntityFramework.ChampionEntity", null)
- .WithMany("Skills")
- .HasForeignKey("ChampionEntityId");
- });
-
- modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
- {
- b.Navigation("Skills");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Sources/EntityFramework/SkinEntity.cs b/Sources/EntityFramework/SkinEntity.cs
index 6035674..8c98d8b 100644
--- a/Sources/EntityFramework/SkinEntity.cs
+++ b/Sources/EntityFramework/SkinEntity.cs
@@ -43,7 +43,11 @@ namespace EntityFramework
//private string description = "";
public string Icon { get; set; }
- public LargeImageEntity Image { get; set; }
+
+
+ //public LargeImageEntity Image { get; set; }
+ public string? Image { get; set; }
+
public float Price { get; set; }
public ChampionEntity Champion { get; set; }
diff --git a/Sources/EntityFramework/StubbedContext.cs b/Sources/EntityFramework/StubbedContext.cs
index 53efd24..a7936e3 100644
--- a/Sources/EntityFramework/StubbedContext.cs
+++ b/Sources/EntityFramework/StubbedContext.cs
@@ -9,26 +9,34 @@ namespace EntityFramework
{
public class StubbedContext : LoLDbContext
{
+ //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ //{
+ // optionsBuilder.EnableSensitiveDataLogging();
+ //}
+
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
- ChampionEntity corichard = new ChampionEntity() {Name="Corichard", Bio="biobiobiobio", Icon="/a/a/a/a"};
+ 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.0 },
- new { Name = "skin", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "bo", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "Joulie", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "Radiance", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "void", ChampionEntityForeignKey = 1, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "Radiance", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "void", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "DarkTheme", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "gold", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 },
- new { Name = "ruby", ChampionEntityForeignKey = 2, Description = "So What", Icon = "/Icon.png", Price = 10.0 }
+ 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 }
);
}
diff --git a/Sources/EntityFramework/champion.db b/Sources/EntityFramework/champion.db
index 662e97286ee8cfaef248c402272a5a70116a24d4..95e56f32d634a0b28a3fe1742eb2c2daa9a8eee9 100644
GIT binary patch
delta 266
zcmZo@U}|V!njkI6%)r3F0mLAh4T#w%>KIEiGwAu(^74LTVB}rGz`KNZ3HNRo+$<>I
z$j!ociSgy+{oI8hM#*Lqol4td
zhx`)*xFq=)oih@13o`TbSa^Zj!Ft~D-{L<8)Uktq^09b3F0j}){@45ufVwX6PkxZE
S0ulSo|CRqe*rdtt>jeQy&_d_{
delta 251
zcmZo@U}|V!njkI6#K6G70mLxCGEv7^nu$R#UW%9h2Ln6zZU(+f{A+o?@h;&p;H~7|
zy;)Gek(;HMon3tLe(pk+CO200%_cmD7+D%4nb{}*;=RGr7{SQC`5K=dBO4?CO$Pp(
zn*|-t^H07hug=8
Date: Mon, 13 Mar 2023 17:10:41 +0100
Subject: [PATCH 5/7] push de migration marchant sans le second hasdata, push
pour merge
---
Sources/EntityFramework/ChampionEntity.cs | 2 +-
.../20230313155631_MyMigr.Designer.cs | 145 ++++++++++++++++
.../Migrations/20230313155631_MyMigr.cs | 110 ++++++++++++
.../Migrations/LoLDbContextModelSnapshot.cs | 142 +++++++++++++++
.../Stubbed/20230313160034_MyMigr.Designer.cs | 161 ++++++++++++++++++
.../Stubbed/20230313160034_MyMigr.cs | 121 +++++++++++++
.../Stubbed/StubbedContextModelSnapshot.cs | 158 +++++++++++++++++
Sources/EntityFramework/StubbedContext.cs | 4 +-
8 files changed, 840 insertions(+), 3 deletions(-)
create mode 100644 Sources/EntityFramework/Migrations/20230313155631_MyMigr.Designer.cs
create mode 100644 Sources/EntityFramework/Migrations/20230313155631_MyMigr.cs
create mode 100644 Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
create mode 100644 Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.Designer.cs
create mode 100644 Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.cs
create mode 100644 Sources/EntityFramework/Migrations/Stubbed/StubbedContextModelSnapshot.cs
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index 8a975d2..1810ae8 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -15,7 +15,7 @@ namespace EntityFramework
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
- public int Id { get; set; } = Guid.NewGuid().GetHashCode();
+ public int Id { get; set; }
[Required]
[MaxLength(50)]
diff --git a/Sources/EntityFramework/Migrations/20230313155631_MyMigr.Designer.cs b/Sources/EntityFramework/Migrations/20230313155631_MyMigr.Designer.cs
new file mode 100644
index 0000000..7c3459c
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/20230313155631_MyMigr.Designer.cs
@@ -0,0 +1,145 @@
+//
+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
+{
+ [DbContext(typeof(LoLDbContext))]
+ [Migration("20230313155631_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);
+ });
+
+ 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/20230313155631_MyMigr.cs b/Sources/EntityFramework/Migrations/20230313155631_MyMigr.cs
new file mode 100644
index 0000000..913356a
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/20230313155631_MyMigr.cs
@@ -0,0 +1,110 @@
+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/LoLDbContextModelSnapshot.cs b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
new file mode 100644
index 0000000..410088f
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/LoLDbContextModelSnapshot.cs
@@ -0,0 +1,142 @@
+//
+using System;
+using EntityFramework;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EntityFramework.Migrations
+{
+ [DbContext(typeof(LoLDbContext))]
+ partial class LoLDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
+
+ modelBuilder.Entity("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);
+ });
+
+ 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.Designer.cs b/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.Designer.cs
new file mode 100644
index 0000000..5fdbb12
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.Designer.cs
@@ -0,0 +1,161 @@
+//
+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
new file mode 100644
index 0000000..a7f4acb
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/Stubbed/20230313160034_MyMigr.cs
@@ -0,0 +1,121 @@
+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
new file mode 100644
index 0000000..3181e7d
--- /dev/null
+++ b/Sources/EntityFramework/Migrations/Stubbed/StubbedContextModelSnapshot.cs
@@ -0,0 +1,158 @@
+//
+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/StubbedContext.cs b/Sources/EntityFramework/StubbedContext.cs
index a7936e3..47aa944 100644
--- a/Sources/EntityFramework/StubbedContext.cs
+++ b/Sources/EntityFramework/StubbedContext.cs
@@ -18,8 +18,8 @@ namespace EntityFramework
{
base.OnModelCreating(modelBuilder);
- 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 {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", Image = new LargeImageEntity { Base64 = "base" } };
//ChampionEntity pintrand = new ChampionEntity { Name = "Pintrand", Bio = "mimimimimim", Icon = "/small.png", Image = new LargeImageEntity { Base64 = "base" } };
From 5423d0f282aa5ac7e337bd5a42549dc2670493d6 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Mon, 13 Mar 2023 18:31:57 +0100
Subject: [PATCH 6/7] 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