From c58e1dd91b03ef55329a1b2c4800efa32395f3f4 Mon Sep 17 00:00:00 2001 From: "arthur.valin" Date: Wed, 1 Feb 2023 17:05:25 +0100 Subject: [PATCH] Adding simple Champion table --- .../DbContexts/ChampionDbContext.cs | 19 ++++++++ .../Entities/ChampionEntity.cs | 17 +++++++ .../EntityFramework.Champions.db | Bin 0 -> 20480 bytes .../EntityFramework.Champions.db-shm | Bin 0 -> 32768 bytes .../EntityFramework.Champions.db-wal | 0 .../EntityFramework/EntityFramework.csproj | 25 ++++++++++ .../20230201154310_migr.Designer.cs | 44 ++++++++++++++++++ .../Migrations/20230201154310_migr.cs | 34 ++++++++++++++ .../ChampionDbContextModelSnapshot.cs | 41 ++++++++++++++++ .../Sources/EntityFramework/Program.cs | 2 + .../Sources/LeagueOfLegends.sln | 8 +++- 11 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 EntityFramework_LoL/Sources/EntityFramework/DbContexts/ChampionDbContext.cs create mode 100644 EntityFramework_LoL/Sources/EntityFramework/Entities/ChampionEntity.cs create mode 100644 EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db create mode 100644 EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-shm create mode 100644 EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-wal create mode 100644 EntityFramework_LoL/Sources/EntityFramework/EntityFramework.csproj create mode 100644 EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.Designer.cs create mode 100644 EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.cs create mode 100644 EntityFramework_LoL/Sources/EntityFramework/Migrations/ChampionDbContextModelSnapshot.cs create mode 100644 EntityFramework_LoL/Sources/EntityFramework/Program.cs diff --git a/EntityFramework_LoL/Sources/EntityFramework/DbContexts/ChampionDbContext.cs b/EntityFramework_LoL/Sources/EntityFramework/DbContexts/ChampionDbContext.cs new file mode 100644 index 0000000..532648c --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/DbContexts/ChampionDbContext.cs @@ -0,0 +1,19 @@ +using EntityFramework.Entities; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EntityFramework.DbContexts +{ + internal class ChampionDbContext : DbContext + { + public DbSet champions { get; set; } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Data Source=EntityFramework.Champions.db"); + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Entities/ChampionEntity.cs b/EntityFramework_LoL/Sources/EntityFramework/Entities/ChampionEntity.cs new file mode 100644 index 0000000..631bfca --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Entities/ChampionEntity.cs @@ -0,0 +1,17 @@ +using System.ComponentModel.DataAnnotations; + +namespace EntityFramework.Entities +{ + internal class ChampionEntity + { + [Key] + [MaxLength(256)] + public string Name { get; set; } + [Required] + [MaxLength(500)] + public string Bio { get; set; } + [Required] + public string Icon { get; set; } + + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db new file mode 100644 index 0000000000000000000000000000000000000000..2643996e4069079cab2a9c289dd5eca80da0fc2f GIT binary patch literal 20480 zcmeI&zi!h&9Ki9jleQ4a4HK5ikdr5nP-MrTtfZ9@R?{S;2DJmSOk%)N6H~{PU~FH6 zC*Wmx1t!!NVB}npv{=r@((3z@Prf_bcm93s#eWW8_me!9AJS|V<8)~iHsIRN)q8;uS&EKMKT#D@<&F{wL_P2FA(~kfG2q1s}0tg_000Iag z@LvSZo!XY!YH1fv9=$(_C!eC(=OmpkR+akR*y{zJ40^kLPg<*fOFlLlQiU~$X0as$ z?**A+GI4I zIQ31_YiS~xPvb9((-ZZq8b)V%dey$3D|A-VZk!)!TV}VbT@0_%3`6hbLGm$+@*>w) z$s$j)ua%wpzv)-*b4{@t)1Q`3yDYM1pbDK)mQK$m`P(>KsFN)Xt2BIl(|p%mr%^di z=u~#s)E#xNxT_3RwB}Et76JhT5I_I{1Q0*~0R#|0009JUufQX%=9(S5 + + + Exe + net6.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.Designer.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.Designer.cs new file mode 100644 index 0000000..7d92db0 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.Designer.cs @@ -0,0 +1,44 @@ +// +using EntityFramework.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFramework.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + [Migration("20230201154310_migr")] + partial class migr + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.cs new file mode 100644 index 0000000..adfed99 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/20230201154310_migr.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EntityFramework.Migrations +{ + /// + public partial class migr : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "champions", + columns: table => new + { + Name = table.Column(type: "TEXT", maxLength: 256, nullable: false), + Bio = table.Column(type: "TEXT", maxLength: 500, nullable: false), + Icon = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_champions", x => x.Name); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "champions"); + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Migrations/ChampionDbContextModelSnapshot.cs b/EntityFramework_LoL/Sources/EntityFramework/Migrations/ChampionDbContextModelSnapshot.cs new file mode 100644 index 0000000..171949d --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Migrations/ChampionDbContextModelSnapshot.cs @@ -0,0 +1,41 @@ +// +using EntityFramework.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace EntityFramework.Migrations +{ + [DbContext(typeof(ChampionDbContext))] + partial class ChampionDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b => + { + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("Bio") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("TEXT"); + + b.Property("Icon") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("champions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/EntityFramework_LoL/Sources/EntityFramework/Program.cs b/EntityFramework_LoL/Sources/EntityFramework/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/EntityFramework_LoL/Sources/LeagueOfLegends.sln index db008a1..da2dfc5 100644 --- a/EntityFramework_LoL/Sources/LeagueOfLegends.sln +++ b/EntityFramework_LoL/Sources/LeagueOfLegends.sln @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API_LoL_Project", "API_LoL_Project\API_LoL_Project.csproj", "{4EDC93E0-35B8-4EF1-9318-24F7A606BA97}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTO", "DTO\DTO.csproj", "{7F6A519E-98F8-429E-B34F-9B0D20075CFB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{7F6A519E-98F8-429E-B34F-9B0D20075CFB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFramework", "EntityFramework\EntityFramework.csproj", "{59CC9D86-8D5A-4D38-B0F3-99B4073C7885}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -49,6 +51,10 @@ Global {7F6A519E-98F8-429E-B34F-9B0D20075CFB}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F6A519E-98F8-429E-B34F-9B0D20075CFB}.Release|Any CPU.ActiveCfg = Release|Any CPU {7F6A519E-98F8-429E-B34F-9B0D20075CFB}.Release|Any CPU.Build.0 = Release|Any CPU + {59CC9D86-8D5A-4D38-B0F3-99B4073C7885}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59CC9D86-8D5A-4D38-B0F3-99B4073C7885}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59CC9D86-8D5A-4D38-B0F3-99B4073C7885}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59CC9D86-8D5A-4D38-B0F3-99B4073C7885}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE