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 0000000..2643996 Binary files /dev/null and b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db differ diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-shm b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-shm new file mode 100644 index 0000000..fe9ac28 Binary files /dev/null and b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-shm differ diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-wal b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.Champions.db-wal new file mode 100644 index 0000000..e69de29 diff --git a/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.csproj b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.csproj new file mode 100644 index 0000000..b6dee0a --- /dev/null +++ b/EntityFramework_LoL/Sources/EntityFramework/EntityFramework.csproj @@ -0,0 +1,25 @@ + + + + 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