From d5d6411ce1167550df7728fd25d5697f14e95c0b Mon Sep 17 00:00:00 2001 From: Louwar Date: Thu, 26 Jan 2023 09:57:24 +0100 Subject: [PATCH] ADD DB --- Sources/ConsoleDB/ConsoleDB.csproj | 10 ++++ Sources/ConsoleDB/Program.cs | 2 + Sources/EFlib/Champion.cs | 20 ++++++++ Sources/EFlib/EFlib.csproj | 23 +++++++++ .../20230126084305_MyMigration.Designer.cs | 47 ++++++++++++++++++ .../Migrations/20230126084305_MyMigration.cs | 36 ++++++++++++++ .../Migrations/SQLiteContextModelSnapshot.cs | 44 ++++++++++++++++ Sources/EFlib/SQLiteContext.cs | 23 +++++++++ Sources/EFlib/SqlServerContext.cs | 20 ++++++++ Sources/EFlib/projet.dbloulou.db | Bin 0 -> 20480 bytes Sources/EFlib/projet.dbloulou.db-shm | Bin 0 -> 32768 bytes Sources/EFlib/projet.dbloulou.db-wal | 0 Sources/LeagueOfLegends.sln | 24 +++++---- Sources/Model/Model.csproj | 9 ++++ Sources/Shared/Shared.csproj | 10 ++++ Sources/StubLib/StubLib.csproj | 10 ++++ .../Tests/ConsoleTests/ConsoleTests.csproj | 7 +++ 17 files changed, 276 insertions(+), 9 deletions(-) create mode 100644 Sources/ConsoleDB/ConsoleDB.csproj create mode 100644 Sources/ConsoleDB/Program.cs create mode 100644 Sources/EFlib/Champion.cs create mode 100644 Sources/EFlib/EFlib.csproj create mode 100644 Sources/EFlib/Migrations/20230126084305_MyMigration.Designer.cs create mode 100644 Sources/EFlib/Migrations/20230126084305_MyMigration.cs create mode 100644 Sources/EFlib/Migrations/SQLiteContextModelSnapshot.cs create mode 100644 Sources/EFlib/SQLiteContext.cs create mode 100644 Sources/EFlib/SqlServerContext.cs create mode 100644 Sources/EFlib/projet.dbloulou.db create mode 100644 Sources/EFlib/projet.dbloulou.db-shm create mode 100644 Sources/EFlib/projet.dbloulou.db-wal diff --git a/Sources/ConsoleDB/ConsoleDB.csproj b/Sources/ConsoleDB/ConsoleDB.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Sources/ConsoleDB/ConsoleDB.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Sources/ConsoleDB/Program.cs b/Sources/ConsoleDB/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/Sources/ConsoleDB/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/Sources/EFlib/Champion.cs b/Sources/EFlib/Champion.cs new file mode 100644 index 0000000..a802c84 --- /dev/null +++ b/Sources/EFlib/Champion.cs @@ -0,0 +1,20 @@ +namespace EFlib +{ + public class Champion + { + /**** Attributs ****/ + public int Id { get; set; } + // https://learn.microsoft.com/fr-fr/ef/core/modeling/keyless-entity-types?tabs=data-annotations + + public string Name { get; set; } + public string Bio { get; set; } + public string Icon { get; set; } + //public Dictionary Characteristics { get; set; } + //public int this + + /**** Méthodes ****/ + //public Champion() { } + + + } +} \ No newline at end of file diff --git a/Sources/EFlib/EFlib.csproj b/Sources/EFlib/EFlib.csproj new file mode 100644 index 0000000..98c38c9 --- /dev/null +++ b/Sources/EFlib/EFlib.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + $(MSBuildProjectDirectory) + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Sources/EFlib/Migrations/20230126084305_MyMigration.Designer.cs b/Sources/EFlib/Migrations/20230126084305_MyMigration.Designer.cs new file mode 100644 index 0000000..e0ff744 --- /dev/null +++ b/Sources/EFlib/Migrations/20230126084305_MyMigration.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(SQLiteContext))] + [Migration("20230126084305_MyMigration")] + partial class MyMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EFlib.Champion", 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/Sources/EFlib/Migrations/20230126084305_MyMigration.cs b/Sources/EFlib/Migrations/20230126084305_MyMigration.cs new file mode 100644 index 0000000..89fd4fc --- /dev/null +++ b/Sources/EFlib/Migrations/20230126084305_MyMigration.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EFlib.Migrations +{ + /// + public partial class MyMigration : 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), + Bio = table.Column(type: "TEXT", nullable: false), + Icon = 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/Sources/EFlib/Migrations/SQLiteContextModelSnapshot.cs b/Sources/EFlib/Migrations/SQLiteContextModelSnapshot.cs new file mode 100644 index 0000000..e8a5bd1 --- /dev/null +++ b/Sources/EFlib/Migrations/SQLiteContextModelSnapshot.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(SQLiteContext))] + partial class SQLiteContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EFlib.Champion", 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/Sources/EFlib/SQLiteContext.cs b/Sources/EFlib/SQLiteContext.cs new file mode 100644 index 0000000..d3c053e --- /dev/null +++ b/Sources/EFlib/SQLiteContext.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EFlib +{ + public class SQLiteContext : DbContext + { + /**** Attributs ****/ + public DbSet Champions { get; set; } + + /**** Méthodes ****/ + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite($"Data Source=projet.dbloulou.db"); + } + + } +} diff --git a/Sources/EFlib/SqlServerContext.cs b/Sources/EFlib/SqlServerContext.cs new file mode 100644 index 0000000..753514e --- /dev/null +++ b/Sources/EFlib/SqlServerContext.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EFlib +{ + internal class SqlServerContext : DbContext + { + /**** Attributs ****/ + public DbSet Champions { get; set; } + /**** Méthodes ****/ + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer($"@\"Server=(localdb)\\mssqllocaldb;Database=projet.dbloulou.mdf;"); + } + } +} diff --git a/Sources/EFlib/projet.dbloulou.db b/Sources/EFlib/projet.dbloulou.db new file mode 100644 index 0000000000000000000000000000000000000000..187c04b2a3694ee313084fe9d7294433665cb233 GIT binary patch literal 20480 zcmeI&-)@>v90%|NYP*>*cSq7>=?PbD+8Cjpsjvbj?Pa$& z+5KK-*Sp#?>|&SuVbm$X2Way>;e_)Cew^P2Za~l8b%NCApQCu}rM$_WGg)S@IcJQ? zR4Y{HCF_^x9okDv?R8C=)!i+n_Lr5F@9f#n+7IOqHBcY`0SG_<0uX=z1Rwwb2tc4f zpkLll_x7Yg>V3NQlbdULU2_xvX5xp#e7DlJh2aS97{?vKbI0z4-q_!#Gk5Plls47v zZRuNO8nb=njlTp@m@FFQl{ngBT;n@Rl~d8ok;YBS5pRUet)9cJ^G=7id)Ap_8#K* z1Rwwb2tWV=5P$##AOHafKmY;{P(YJPhT6~@P5q$pN3jHl~A0%X7c)1UrPAOHafKmY;|fB*y_ q009U<00Izr!~%H#f5bNzsX+h&5P$##AOHafKmY;|fB*z$0{;Metl2{V literal 0 HcmV?d00001 diff --git a/Sources/EFlib/projet.dbloulou.db-shm b/Sources/EFlib/projet.dbloulou.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10 GIT binary patch literal 32768 zcmeIuAr62r3 + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Sources/Shared/Shared.csproj b/Sources/Shared/Shared.csproj index bafd05b..fc454d5 100644 --- a/Sources/Shared/Shared.csproj +++ b/Sources/Shared/Shared.csproj @@ -6,4 +6,14 @@ enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Sources/StubLib/StubLib.csproj b/Sources/StubLib/StubLib.csproj index f05027c..a6d91c5 100644 --- a/Sources/StubLib/StubLib.csproj +++ b/Sources/StubLib/StubLib.csproj @@ -6,6 +6,16 @@ enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Sources/Tests/ConsoleTests/ConsoleTests.csproj b/Sources/Tests/ConsoleTests/ConsoleTests.csproj index 1602b94..090f31e 100644 --- a/Sources/Tests/ConsoleTests/ConsoleTests.csproj +++ b/Sources/Tests/ConsoleTests/ConsoleTests.csproj @@ -15,6 +15,13 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +