From bc7de911eb07f58d04392d40d3a24fbc09142a77 Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Thu, 26 Jan 2023 09:56:23 +0100 Subject: [PATCH] une db qui marche --- .../Sources/ConsoleDb/ConsoleDb.csproj | 13 +++++ .../Sources/ConsoleDb/Program.cs | 4 ++ .../Sources/EFLib/ChampionEntity.cs | 17 +++++++ .../Sources/EFLib/EFLib.csproj | 29 +++++++++++ .../Sources/EFLib/LolContext.cs | 13 +++++ .../20230126083419_oiseaux.Designer.cs | 47 ++++++++++++++++++ .../Migrations/20230126083419_oiseaux.cs | 36 ++++++++++++++ .../Migrations/LolContextModelSnapshot.cs | 44 ++++++++++++++++ EntityFramework_LoL/Sources/EFLib/Program.cs | 3 ++ EntityFramework_LoL/Sources/EFLib/oiseaux.db | Bin 0 -> 20480 bytes .../Sources/LeagueOfLegends.sln | 12 +++++ .../Sources/Model/Model.csproj | 19 +++++++ .../Sources/Shared/Shared.csproj | 18 +++++++ .../Sources/StubLib/StubLib.csproj | 18 +++++++ .../Tests/ConsoleTests/ConsoleTests.csproj | 14 ++++++ 15 files changed, 287 insertions(+) create mode 100644 EntityFramework_LoL/Sources/ConsoleDb/ConsoleDb.csproj create mode 100644 EntityFramework_LoL/Sources/ConsoleDb/Program.cs create mode 100644 EntityFramework_LoL/Sources/EFLib/ChampionEntity.cs create mode 100644 EntityFramework_LoL/Sources/EFLib/EFLib.csproj create mode 100644 EntityFramework_LoL/Sources/EFLib/LolContext.cs create mode 100644 EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.Designer.cs create mode 100644 EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.cs create mode 100644 EntityFramework_LoL/Sources/EFLib/Migrations/LolContextModelSnapshot.cs create mode 100644 EntityFramework_LoL/Sources/EFLib/Program.cs create mode 100644 EntityFramework_LoL/Sources/EFLib/oiseaux.db diff --git a/EntityFramework_LoL/Sources/ConsoleDb/ConsoleDb.csproj b/EntityFramework_LoL/Sources/ConsoleDb/ConsoleDb.csproj new file mode 100644 index 0000000..8c3f25a --- /dev/null +++ b/EntityFramework_LoL/Sources/ConsoleDb/ConsoleDb.csproj @@ -0,0 +1,13 @@ + + + + Exe + net6.0 + enable + enable + + + + + + diff --git a/EntityFramework_LoL/Sources/ConsoleDb/Program.cs b/EntityFramework_LoL/Sources/ConsoleDb/Program.cs new file mode 100644 index 0000000..08b7c8d --- /dev/null +++ b/EntityFramework_LoL/Sources/ConsoleDb/Program.cs @@ -0,0 +1,4 @@ +using EFLib; + +ChampionEntity ChampionEntity + diff --git a/EntityFramework_LoL/Sources/EFLib/ChampionEntity.cs b/EntityFramework_LoL/Sources/EFLib/ChampionEntity.cs new file mode 100644 index 0000000..d2ec9a0 --- /dev/null +++ b/EntityFramework_LoL/Sources/EFLib/ChampionEntity.cs @@ -0,0 +1,17 @@ +using System; +namespace EFLib +{ + public class ChampionEntity + { + + public int Id { get; set; } + + public string Name { get; set; } + + public string Icon { get; set; } + + public string Bio { get; set; } + + } +} + diff --git a/EntityFramework_LoL/Sources/EFLib/EFLib.csproj b/EntityFramework_LoL/Sources/EFLib/EFLib.csproj new file mode 100644 index 0000000..fcb4a9f --- /dev/null +++ b/EntityFramework_LoL/Sources/EFLib/EFLib.csproj @@ -0,0 +1,29 @@ + + + + Exe + net6.0 + enable + enable + $(MSBuildProjectDirectory) + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + diff --git a/EntityFramework_LoL/Sources/EFLib/LolContext.cs b/EntityFramework_LoL/Sources/EFLib/LolContext.cs new file mode 100644 index 0000000..664a267 --- /dev/null +++ b/EntityFramework_LoL/Sources/EFLib/LolContext.cs @@ -0,0 +1,13 @@ +using System; +using Microsoft.EntityFrameworkCore; + +namespace EFLib +{ + public class LolContext : DbContext + { + public DbSet Champions { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlite("Data Source=oiseaux.db"); + } +} + diff --git a/EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.Designer.cs b/EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.Designer.cs new file mode 100644 index 0000000..15b2f75 --- /dev/null +++ b/EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.Designer.cs @@ -0,0 +1,47 @@ +// +using EFLib; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EFLib.Migrations +{ + [DbContext(typeof(LolContext))] + [Migration("20230126083419_oiseaux")] + partial class oiseaux + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EFLib.ChampionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.cs b/EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.cs new file mode 100644 index 0000000..7336329 --- /dev/null +++ b/EntityFramework_LoL/Sources/EFLib/Migrations/20230126083419_oiseaux.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EFLib.Migrations +{ + /// + public partial class oiseaux : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "champions", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: false), + Icon = table.Column(type: "TEXT", nullable: false), + Bio = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_champions", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "champions"); + } + } +} diff --git a/EntityFramework_LoL/Sources/EFLib/Migrations/LolContextModelSnapshot.cs b/EntityFramework_LoL/Sources/EFLib/Migrations/LolContextModelSnapshot.cs new file mode 100644 index 0000000..e3c0e56 --- /dev/null +++ b/EntityFramework_LoL/Sources/EFLib/Migrations/LolContextModelSnapshot.cs @@ -0,0 +1,44 @@ +// +using EFLib; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EFLib.Migrations +{ + [DbContext(typeof(LolContext))] + partial class LolContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EFLib.ChampionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EFLib/Program.cs b/EntityFramework_LoL/Sources/EFLib/Program.cs new file mode 100644 index 0000000..3ed0e5d --- /dev/null +++ b/EntityFramework_LoL/Sources/EFLib/Program.cs @@ -0,0 +1,3 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); + diff --git a/EntityFramework_LoL/Sources/EFLib/oiseaux.db b/EntityFramework_LoL/Sources/EFLib/oiseaux.db new file mode 100644 index 0000000000000000000000000000000000000000..adc9f7bbad9d2755933707b42c928a2d8c93a081 GIT binary patch literal 20480 zcmeI&y>8P`6bJBoowS8WA#4^5^vYACR#83>AscRW0jr4& z5g3)X)%|@wN!<5mUVMH=uWe53oiDs#n(uBMSyH#9u=T^f6uD#f0(b5m(3$ni)6$N* zyUVY>E^|&lx%1C{7{seac_WXu8rQ^LMNnwQOcRD_%U9A8=Fk@AxZf8?L-WM8bQ%}h z=-631Yh)P%-I|DFIT8BU9vUWHU?5HV;9okER;CGCzNJiAwrs|jhC%Vnp&#ZZD)q}T z-%-0=eq}5Ra~%0{;D3zVB(3hXA17h-rEpN$EV%HPRq?Boslvvh^8`2KS>wpc97W-5 zF-=arD5j<6vR3MbvaP=Ba^?p!?;^Xc?ji}7eW&m$POEUZL=W1%^kJ*g&TBszZ3qZJ z00Izz00bZa0SG_<0uX=z1a7Io6JF}6?Pj~vY_*>?pLd?NdQRxap1Zi{Hkyrgh3ew9 zUyL>c1Rwwb2tWV=5P$##AOHafKmY=_THsNscfa^cfb{o&`qMuG0uX=z1Rwwb2tWV= p5P$##AOL|oEP(g_JA89d8U!E!0SG_<0uX=z1Rwwb2tXhc_zOu5*82be literal 0 HcmV?d00001 diff --git a/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/EntityFramework_LoL/Sources/LeagueOfLegends.sln index 0ea57ff..ee0f61a 100644 --- a/EntityFramework_LoL/Sources/LeagueOfLegends.sln +++ b/EntityFramework_LoL/Sources/LeagueOfLegends.sln @@ -15,6 +15,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stub", "Stub", "{2C607793-B EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubLib", "StubLib\StubLib.csproj", "{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFLib", "EFLib\EFLib.csproj", "{D331DDC5-0CC9-4C6A-802A-31C528617602}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleDb", "ConsoleDb\ConsoleDb.csproj", "{30AF9CBD-1E40-46F2-973F-6C13F1E15660}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -37,6 +41,14 @@ Global {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB}.Release|Any CPU.Build.0 = Release|Any CPU + {D331DDC5-0CC9-4C6A-802A-31C528617602}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D331DDC5-0CC9-4C6A-802A-31C528617602}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D331DDC5-0CC9-4C6A-802A-31C528617602}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D331DDC5-0CC9-4C6A-802A-31C528617602}.Release|Any CPU.Build.0 = Release|Any CPU + {30AF9CBD-1E40-46F2-973F-6C13F1E15660}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30AF9CBD-1E40-46F2-973F-6C13F1E15660}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30AF9CBD-1E40-46F2-973F-6C13F1E15660}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30AF9CBD-1E40-46F2-973F-6C13F1E15660}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/EntityFramework_LoL/Sources/Model/Model.csproj b/EntityFramework_LoL/Sources/Model/Model.csproj index 27b2839..f898697 100644 --- a/EntityFramework_LoL/Sources/Model/Model.csproj +++ b/EntityFramework_LoL/Sources/Model/Model.csproj @@ -1,13 +1,19 @@ + net6.0 enable enable + $(MSBuildProjectDirectory) + + + + @@ -15,4 +21,17 @@ + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/EntityFramework_LoL/Sources/Shared/Shared.csproj b/EntityFramework_LoL/Sources/Shared/Shared.csproj index bafd05b..addd042 100644 --- a/EntityFramework_LoL/Sources/Shared/Shared.csproj +++ b/EntityFramework_LoL/Sources/Shared/Shared.csproj @@ -6,4 +6,22 @@ enable + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/EntityFramework_LoL/Sources/StubLib/StubLib.csproj b/EntityFramework_LoL/Sources/StubLib/StubLib.csproj index f05027c..6d93d37 100644 --- a/EntityFramework_LoL/Sources/StubLib/StubLib.csproj +++ b/EntityFramework_LoL/Sources/StubLib/StubLib.csproj @@ -9,4 +9,22 @@ + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj b/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj index 1602b94..039482e 100644 --- a/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj +++ b/EntityFramework_LoL/Sources/Tests/ConsoleTests/ConsoleTests.csproj @@ -13,8 +13,22 @@ + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + +