diff --git a/.vs/LolProject/v17/.suo b/.vs/LolProject/v17/.suo index d3190ef..d173a87 100644 Binary files a/.vs/LolProject/v17/.suo and b/.vs/LolProject/v17/.suo differ diff --git a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln b/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln index df59485..a1cac0d 100644 --- a/src/EntityFramework_LoL/Sources/LeagueOfLegends.sln +++ b/src/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}") = "ApiLol", "ApiLol\ApiLol.csproj", "{D59C9C7B-9BC2-4601-959D-BFA97E46D017}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyFlib", "MyFlib\MyFlib.csproj", "{2142AB69-B483-4B0A-96DC-CFA87DEB11A5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -49,6 +51,10 @@ Global {3919E408-EB12-4422-989B-C6ED4816D465}.Debug|Any CPU.Build.0 = Debug|Any CPU {3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.ActiveCfg = Release|Any CPU {3919E408-EB12-4422-989B-C6ED4816D465}.Release|Any CPU.Build.0 = Release|Any CPU + {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2142AB69-B483-4B0A-96DC-CFA87DEB11A5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/EntityFramework_LoL/Sources/MyFlib/ChampionEntity.cs b/src/EntityFramework_LoL/Sources/MyFlib/ChampionEntity.cs new file mode 100644 index 0000000..0f25121 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/ChampionEntity.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyFlib +{ + public class ChampionEntity + { + [Key] + public string Name { get; set; } + public ChampionEntity(string name) + { + Name = name; + } + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db new file mode 100644 index 0000000..13315b3 Binary files /dev/null and b/src/EntityFramework_LoL/Sources/MyFlib/DataBase.db differ diff --git a/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs new file mode 100644 index 0000000..71e5157 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MyFlib +{ + public class LolDbContext: DbContext + { + public DbSet Champions { get; set; } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + optionsBuilder.UseSqlite(@"Data Source=DataBase.db"); + } + } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasData(new ChampionEntity("Akali")); + } + + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.Designer.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.Designer.cs new file mode 100644 index 0000000..6ce17ec --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.Designer.cs @@ -0,0 +1,40 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyFlib; + +#nullable disable + +namespace MyFlib.Migrations +{ + [DbContext(typeof(LolDbContext))] + [Migration("20230201163620_MyMigration")] + partial class MyMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("MyFlib.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Champions"); + + b.HasData( + new + { + Name = "Akali" + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.cs new file mode 100644 index 0000000..8716d00 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MyFlib.Migrations +{ + /// + public partial class MyMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Champions", + columns: table => new + { + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Champions", x => x.Name); + }); + + migrationBuilder.InsertData( + table: "Champions", + column: "Name", + value: "Akali"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Champions"); + } + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs new file mode 100644 index 0000000..5f71390 --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs @@ -0,0 +1,37 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using MyFlib; + +#nullable disable + +namespace MyFlib.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("MyFlib.ChampionEntity", b => + { + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Champions"); + + b.HasData( + new + { + Name = "Akali" + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj b/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj new file mode 100644 index 0000000..f99623c --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj @@ -0,0 +1,25 @@ + + + + Exe + net6.0 + enable + enable + $(MSBuildProjectDirectory) + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/src/EntityFramework_LoL/Sources/MyFlib/Program.cs b/src/EntityFramework_LoL/Sources/MyFlib/Program.cs new file mode 100644 index 0000000..ef4ef6d --- /dev/null +++ b/src/EntityFramework_LoL/Sources/MyFlib/Program.cs @@ -0,0 +1,10 @@ +// See https://aka.ms/new-console-template for more information +using MyFlib; + +Console.WriteLine("Hello, World!"); + +using(var context = new LolDbContext()) +{ + //var champions = context.Champions.where + context.SaveChangesAsync(); // or context.SaveChangesAsync +} \ No newline at end of file