From 6c2cd1d33923ee92ff31c3b2c511e96be8b1b281 Mon Sep 17 00:00:00 2001 From: "emre.kartal" Date: Wed, 1 Feb 2023 17:45:11 +0100 Subject: [PATCH] Creating DataBase, Entity Champion and DBContext :white_check_mark: --- .vs/LolProject/v17/.suo | Bin 13824 -> 12800 bytes .../Sources/LeagueOfLegends.sln | 8 +++- .../Sources/MyFlib/ChampionEntity.cs | 19 +++++++++ .../Sources/MyFlib/DataBase.db | Bin 0 -> 20480 bytes .../Sources/MyFlib/LolDbContext.cs | 26 ++++++++++++ .../20230201163620_MyMigration.Designer.cs | 40 ++++++++++++++++++ .../Migrations/20230201163620_MyMigration.cs | 37 ++++++++++++++++ .../Migrations/LolDbContextModelSnapshot.cs | 37 ++++++++++++++++ .../Sources/MyFlib/MyFlib.csproj | 25 +++++++++++ .../Sources/MyFlib/Program.cs | 10 +++++ 10 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/ChampionEntity.cs create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/DataBase.db create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/LolDbContext.cs create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.Designer.cs create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/Migrations/20230201163620_MyMigration.cs create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/Migrations/LolDbContextModelSnapshot.cs create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/MyFlib.csproj create mode 100644 src/EntityFramework_LoL/Sources/MyFlib/Program.cs diff --git a/.vs/LolProject/v17/.suo b/.vs/LolProject/v17/.suo index d3190eff2d84debdc910ff8157ca8d8816dcad71..d173a870bd5da057848024bbf125a2747188c1ef 100644 GIT binary patch delta 1117 zcmb_a&ubGw6yDiPOw!KghlxqsY?>NV1W6>xCaD3H#(G#tBzy1=Xibbgc<``7kMZE$ z=AAqV-n>co9}rRy6ctY*UIfpALJrAAeQ!5YS|Os~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1sWitUAH!qn8ang z2v5MvaOT8Ij3aKxvVu}^M3uglt=K=sj(;EJ;^gpoCr%>ub~>AciE4;DLQ3&SDItWR z+m>!OWiig*4D?m5^w)I_Q4Q{v%%37(-V^0-=GXFG`OCVSi6ejj0tg_000IagfB*sr z{6~RLxq?-x$jhfm_<9_*-iMRZczQBVJNeeobA3@;qx`=z4N#qNcZ$X330 zMiayTI#`>%p zgy+e0Ili41)YBEVE{|lvYBuHP{&L4b;63Ta?`C1L*!Ht{o=j&KnL*>vOfv7e%_?29 zJ^Dv-YZh8b^xmO0mQYEGl()av#9#=cVvx)7@0R#|0009ILKmY**5I|sK1@7hC-Sr;OV literal 0 HcmV?d00001 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