diff --git a/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.Designer.cs b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.Designer.cs new file mode 100644 index 0000000..a180f95 --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.Designer.cs @@ -0,0 +1,182 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DbConsole.Migrations +{ + [DbContext(typeof(SQLiteContext))] + [Migration("20230321112754_AllMigrations")] + partial class AllMigrations + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Property("PlayerId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxPoints") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbPlayed") + .HasColumnType("INTEGER"); + + b.Property("NbWin") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("PlayerId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPointsTotal") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany("Scores") + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany("Scores") + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Navigation("Scores"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.cs b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.cs new file mode 100644 index 0000000..f30d7c3 --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/20230321112754_AllMigrations.cs @@ -0,0 +1,150 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DbConsole.Migrations +{ + /// + public partial class AllMigrations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Case", + columns: table => new + { + CaseId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Value = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Case", x => x.CaseId); + }); + + migrationBuilder.CreateTable( + name: "Game", + columns: table => new + { + GameId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Duration = table.Column(type: "TEXT", nullable: false), + Date = table.Column(type: "TEXT", nullable: false), + NbPlayers = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Game", x => x.GameId); + }); + + migrationBuilder.CreateTable( + name: "Grille", + columns: table => new + { + GrilleId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbChains = table.Column(type: "INTEGER", nullable: false), + NbZones = table.Column(type: "INTEGER", nullable: false), + MaxChain = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Grille", x => x.GrilleId); + }); + + migrationBuilder.CreateTable( + name: "Players", + columns: table => new + { + PlayerId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Pseudo = table.Column(type: "TEXT", nullable: false), + NbWin = table.Column(type: "INTEGER", nullable: false), + NbPlayed = table.Column(type: "INTEGER", nullable: false), + MaxZone = table.Column(type: "INTEGER", nullable: false), + MaxPoints = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Players", x => x.PlayerId); + }); + + migrationBuilder.CreateTable( + name: "Turn", + columns: table => new + { + TurnId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + DiceValue1 = table.Column(type: "INTEGER", nullable: false), + DiceValue2 = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Turn", x => x.TurnId); + }); + + migrationBuilder.CreateTable( + name: "Score", + columns: table => new + { + ScoreId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + NbPointsTotal = table.Column(type: "INTEGER", nullable: false), + GameId = table.Column(type: "INTEGER", nullable: false), + PlayerId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Score", x => x.ScoreId); + table.ForeignKey( + name: "FK_Score_Game_GameId", + column: x => x.GameId, + principalTable: "Game", + principalColumn: "GameId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Score_Players_PlayerId", + column: x => x.PlayerId, + principalTable: "Players", + principalColumn: "PlayerId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Score_GameId", + table: "Score", + column: "GameId"); + + migrationBuilder.CreateIndex( + name: "IX_Score_PlayerId", + table: "Score", + column: "PlayerId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Case"); + + migrationBuilder.DropTable( + name: "Grille"); + + migrationBuilder.DropTable( + name: "Score"); + + migrationBuilder.DropTable( + name: "Turn"); + + migrationBuilder.DropTable( + name: "Game"); + + migrationBuilder.DropTable( + name: "Players"); + } + } +} diff --git a/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs b/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs new file mode 100644 index 0000000..5b4d8bc --- /dev/null +++ b/Sources/Tests/DbConsole/Migrations/SQLiteContextModelSnapshot.cs @@ -0,0 +1,179 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DbConsole.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("EntityFrameWorkLib.CaseEntity", b => + { + b.Property("CaseId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("INTEGER"); + + b.HasKey("CaseId"); + + b.ToTable("Case"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Property("GameId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbPlayers") + .HasColumnType("INTEGER"); + + b.HasKey("GameId"); + + b.ToTable("Game"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b => + { + b.Property("GrilleId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxChain") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbChains") + .HasColumnType("INTEGER"); + + b.Property("NbZones") + .HasColumnType("INTEGER"); + + b.HasKey("GrilleId"); + + b.ToTable("Grille"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Property("PlayerId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("MaxPoints") + .HasColumnType("INTEGER"); + + b.Property("MaxZone") + .HasColumnType("INTEGER"); + + b.Property("NbPlayed") + .HasColumnType("INTEGER"); + + b.Property("NbWin") + .HasColumnType("INTEGER"); + + b.Property("Pseudo") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("PlayerId"); + + b.ToTable("Players"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.Property("ScoreId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameId") + .HasColumnType("INTEGER"); + + b.Property("NbPointsTotal") + .HasColumnType("INTEGER"); + + b.Property("PlayerId") + .HasColumnType("INTEGER"); + + b.HasKey("ScoreId"); + + b.HasIndex("GameId"); + + b.HasIndex("PlayerId"); + + b.ToTable("Score"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b => + { + b.Property("TurnId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DiceValue1") + .HasColumnType("INTEGER"); + + b.Property("DiceValue2") + .HasColumnType("INTEGER"); + + b.HasKey("TurnId"); + + b.ToTable("Turn"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b => + { + b.HasOne("EntityFrameWorkLib.GameEntity", "Game") + .WithMany("Scores") + .HasForeignKey("GameId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("EntityFrameWorkLib.PlayerEntity", "Player") + .WithMany("Scores") + .HasForeignKey("PlayerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Game"); + + b.Navigation("Player"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b => + { + b.Navigation("Scores"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Sources/Tests/DbConsole/Program.cs b/Sources/Tests/DbConsole/Program.cs index 0b4c5db..04a07cb 100644 --- a/Sources/Tests/DbConsole/Program.cs +++ b/Sources/Tests/DbConsole/Program.cs @@ -25,6 +25,7 @@ using Model; context.SaveChanges(); }*/ +// Ajout de 3 Game, 1 Player "Jax" et 3 Scores totaux dans chaque Game attribués au Player par son Id using (var context = new SQLiteContext()) { var firstGame = new GameEntity diff --git a/Sources/Tests/DbConsole/projet.ToutesTables.db b/Sources/Tests/DbConsole/projet.ToutesTables.db new file mode 100644 index 0000000..64c5432 Binary files /dev/null and b/Sources/Tests/DbConsole/projet.ToutesTables.db differ