Ajout de l'entité ParticipateEntity et début des tests méthodes du model
continuous-integration/drone/push Build is failing Details

EF
Théo DUPIN 2 years ago
parent 8e4db752ea
commit 87a98a5449

@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Model\Model.csproj" />
<ProjectReference Include="..\..\Stub\Stub\Stub.csproj" />
<ProjectReference Include="..\..\Trek12_Lib\EntityFrameWorkLib.csproj" />
</ItemGroup>
<ItemGroup>

@ -1,182 +0,0 @@
// <auto-generated />
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
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFrameWorkLib.CaseEntity", b =>
{
b.Property<int>("CaseId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("CaseId");
b.ToTable("Case");
});
modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b =>
{
b.Property<int>("GameId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<TimeSpan>("Duration")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbPlayers")
.HasColumnType("INTEGER");
b.HasKey("GameId");
b.ToTable("Game");
});
modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b =>
{
b.Property<int>("GrilleId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxChain")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbChains")
.HasColumnType("INTEGER");
b.Property<int>("NbZones")
.HasColumnType("INTEGER");
b.HasKey("GrilleId");
b.ToTable("Grille");
});
modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b =>
{
b.Property<int>("PlayerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxPoints")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbPlayed")
.HasColumnType("INTEGER");
b.Property<int>("NbWin")
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("PlayerId");
b.ToTable("Players");
});
modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b =>
{
b.Property<int>("ScoreId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("NbPointsTotal")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("ScoreId");
b.HasIndex("GameId");
b.HasIndex("PlayerId");
b.ToTable("Score");
});
modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b =>
{
b.Property<int>("TurnId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("DiceValue1")
.HasColumnType("INTEGER");
b.Property<int>("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
}
}
}

@ -1,150 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DbConsole.Migrations
{
/// <inheritdoc />
public partial class AllMigrations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Case",
columns: table => new
{
CaseId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Value = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Case", x => x.CaseId);
});
migrationBuilder.CreateTable(
name: "Game",
columns: table => new
{
GameId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Duration = table.Column<TimeSpan>(type: "TEXT", nullable: false),
Date = table.Column<DateOnly>(type: "TEXT", nullable: false),
NbPlayers = table.Column<int>(type: "INTEGER", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Game", x => x.GameId);
});
migrationBuilder.CreateTable(
name: "Grille",
columns: table => new
{
GrilleId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NbChains = table.Column<int>(type: "INTEGER", nullable: false),
NbZones = table.Column<int>(type: "INTEGER", nullable: false),
MaxChain = table.Column<int>(type: "INTEGER", nullable: false),
MaxZone = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Grille", x => x.GrilleId);
});
migrationBuilder.CreateTable(
name: "Players",
columns: table => new
{
PlayerId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Pseudo = table.Column<string>(type: "TEXT", nullable: false),
NbWin = table.Column<int>(type: "INTEGER", nullable: false),
NbPlayed = table.Column<int>(type: "INTEGER", nullable: false),
MaxZone = table.Column<int>(type: "INTEGER", nullable: false),
MaxPoints = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Players", x => x.PlayerId);
});
migrationBuilder.CreateTable(
name: "Turn",
columns: table => new
{
TurnId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
DiceValue1 = table.Column<int>(type: "INTEGER", nullable: false),
DiceValue2 = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Turn", x => x.TurnId);
});
migrationBuilder.CreateTable(
name: "Score",
columns: table => new
{
ScoreId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NbPointsTotal = table.Column<int>(type: "INTEGER", nullable: false),
GameId = table.Column<int>(type: "INTEGER", nullable: false),
PlayerId = table.Column<int>(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");
}
/// <inheritdoc />
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");
}
}
}

@ -1,179 +0,0 @@
// <auto-generated />
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<int>("CaseId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Value")
.HasColumnType("INTEGER");
b.HasKey("CaseId");
b.ToTable("Case");
});
modelBuilder.Entity("EntityFrameWorkLib.GameEntity", b =>
{
b.Property<int>("GameId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<TimeSpan>("Duration")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbPlayers")
.HasColumnType("INTEGER");
b.HasKey("GameId");
b.ToTable("Game");
});
modelBuilder.Entity("EntityFrameWorkLib.GrilleEntity", b =>
{
b.Property<int>("GrilleId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxChain")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbChains")
.HasColumnType("INTEGER");
b.Property<int>("NbZones")
.HasColumnType("INTEGER");
b.HasKey("GrilleId");
b.ToTable("Grille");
});
modelBuilder.Entity("EntityFrameWorkLib.PlayerEntity", b =>
{
b.Property<int>("PlayerId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("MaxPoints")
.HasColumnType("INTEGER");
b.Property<int>("MaxZone")
.HasColumnType("INTEGER");
b.Property<int>("NbPlayed")
.HasColumnType("INTEGER");
b.Property<int>("NbWin")
.HasColumnType("INTEGER");
b.Property<string>("Pseudo")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("PlayerId");
b.ToTable("Players");
});
modelBuilder.Entity("EntityFrameWorkLib.ScoreEntity", b =>
{
b.Property<int>("ScoreId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("GameId")
.HasColumnType("INTEGER");
b.Property<int>("NbPointsTotal")
.HasColumnType("INTEGER");
b.Property<int>("PlayerId")
.HasColumnType("INTEGER");
b.HasKey("ScoreId");
b.HasIndex("GameId");
b.HasIndex("PlayerId");
b.ToTable("Score");
});
modelBuilder.Entity("EntityFrameWorkLib.TurnEntity", b =>
{
b.Property<int>("TurnId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("DiceValue1")
.HasColumnType("INTEGER");
b.Property<int>("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
}
}
}

@ -1,6 +1,8 @@
using EntityFrameWorkLib;
using Microsoft.EntityFrameworkCore;
using Model;
using Stub;
/*GameEntity g1 = new GameEntity
{
@ -17,7 +19,7 @@ using Model;
MaxPoints = 0,
};*/
/*using (var context = new SQLiteContext())
/*using (var context = new TrekContext())
{
Console.WriteLine("Create and Insert new Player");
context.Add(p1);
@ -26,7 +28,7 @@ using Model;
}*/
// 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())
/*using (var context = new TrekContext())
{
var firstGame = new GameEntity
{
@ -58,15 +60,56 @@ using (var context = new SQLiteContext())
context.AddRange(firstGame, secondGame, thirdGame, newPlayer);
context.AddRange(scores);
context.SaveChanges();
}
}*/
public class SQLiteContext : TrekContext
/*using(var context = new TrekContext())
{
protected override void OnConfiguring(DbContextOptionsBuilder options)
var grille = new GrilleEntity
{
GrilleId = 1,
NbChains = 1,
NbZones = 4,
MaxChain = 20,
MaxZone = 25
};
var case1 = new CaseEntity
{
if (!options.IsConfigured)
CaseId = 1,
Value = 5,
GrilleId = 1
};
var case2 = new CaseEntity
{
options.UseSqlite($"Data Source=projet.ToutesTables.db");
}
CaseId = 2,
Value = 10,
GrilleId = 1
};
var case3 = new CaseEntity
{
CaseId = 3,
Value = 12,
GrilleId = 1
};
context.AddRange(grille, case1, case2, case3);
context.SaveChanges();
*/
using (var context = new TrekContext())
{
var grille = new GrilleEntity
{
GrilleId = 1,
Cases = new List<CaseEntity>
{
new CaseEntity { CaseId = 1, GrilleId = 1, Value = 2 },
new CaseEntity { CaseId = 2, GrilleId = 1, Value = 5 },
new CaseEntity { CaseId = 3, GrilleId = 1, Value = 10 },
new CaseEntity { CaseId = 4, GrilleId = 1, Value = 12 },
new CaseEntity { CaseId = 5, GrilleId = 1, Value = 7 }
}
};
context.Add(grille);
context.SaveChanges();
}

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="GetEFProjectMetadata">
<MSBuild Condition=" '$(TargetFramework)' == '' "
Projects="$(MSBuildProjectFile)"
Targets="GetEFProjectMetadata"
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0]);EFProjectMetadataFile=$(EFProjectMetadataFile)" />
<ItemGroup Condition=" '$(TargetFramework)' != '' ">
<EFProjectMetadata Include="AssemblyName: $(AssemblyName)" />
<EFProjectMetadata Include="Language: $(Language)" />
<EFProjectMetadata Include="OutputPath: $(OutputPath)" />
<EFProjectMetadata Include="Platform: $(Platform)" />
<EFProjectMetadata Include="PlatformTarget: $(PlatformTarget)" />
<EFProjectMetadata Include="ProjectAssetsFile: $(ProjectAssetsFile)" />
<EFProjectMetadata Include="ProjectDir: $(ProjectDir)" />
<EFProjectMetadata Include="RootNamespace: $(RootNamespace)" />
<EFProjectMetadata Include="RuntimeFrameworkVersion: $(RuntimeFrameworkVersion)" />
<EFProjectMetadata Include="TargetFileName: $(TargetFileName)" />
<EFProjectMetadata Include="TargetFrameworkMoniker: $(TargetFrameworkMoniker)" />
<EFProjectMetadata Include="Nullable: $(Nullable)" />
<EFProjectMetadata Include="TargetFramework: $(TargetFramework)" />
<EFProjectMetadata Include="TargetPlatformIdentifier: $(TargetPlatformIdentifier)" />
</ItemGroup>
<WriteLinesToFile Condition=" '$(TargetFramework)' != '' "
File="$(EFProjectMetadataFile)"
Lines="@(EFProjectMetadata)" />
</Target>
</Project>

@ -9,7 +9,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -21,4 +24,9 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Stub\Stub\Stub.csproj" />
<ProjectReference Include="..\..\Trek12_Lib\EntityFrameWorkLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,23 @@
using EntityFrameWorkLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Model;
using NUnit.Framework.Internal;
using Stub;
using System.Data;
using static Stub.StubData;
namespace ModelTest
{
public class Test_Stub
{
[Fact]
public void Test_AddNewPlayer()
{
Player player = new Player("Jax");
GameMode gameMode = new GameMode("Classique");
DateOnly dateTime = new DateOnly(2023, 01, 01);
Game game = new Game(dateTime, player, gameMode, 1);
}
}
}

@ -1,11 +0,0 @@
namespace ModelTest
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,7 +10,13 @@ namespace EntityFrameWorkLib
{
public class CaseEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int CaseId { get; set; }
[ForeignKey("GrilleId")]
public int GrilleId { get; set; }
public GrilleEntity Grille { get; set; }
public int Value { get; set; }
}
}

@ -16,8 +16,8 @@ namespace EntityFrameWorkLib
public TimeSpan Duration { get; set; }
public DateOnly Date { get; set; }
public int NbPlayers { get; set; }
public string Name { get; set; }
public List<ScoreEntity> Scores { get; set; }
public PlayerEntity Player { get; set; }
public string? Name { get; set; }
public List<ScoreEntity>? Scores { get; set; }
}
}

@ -17,5 +17,6 @@ namespace EntityFrameWorkLib
public int NbZones { get; set; }
public int MaxChain { get; set; }
public int MaxZone { get; set; }
public List<CaseEntity> Cases { get; set; }
}
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFrameWorkLib
{
public class ParticipateEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[ForeignKey("GrilleId")]
public int GrilleId { get; set; }
public GrilleEntity Grille { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[ForeignKey("GameId")]
public int GameId { get; set; }
public GameEntity Game { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[ForeignKey("PlayerId")]
public int PlayerId { get; set; }
public PlayerEntity Player { get; set; }
}
}

@ -9,12 +9,11 @@ namespace EntityFrameWorkLib
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int PlayerId { get; set; }
public string Pseudo { get; set; }
public string? Pseudo { get; set; }
public int NbWin { get; set; }
public int NbPlayed { get; set; }
public int MaxZone { get; set; }
public int MaxPoints { get; set; }
public List<ScoreEntity> Scores { get; set; }
}
}

@ -10,17 +10,12 @@ namespace EntityFrameWorkLib
{
public class ScoreEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ScoreId { get; set; }
public int NbPointsTotal { get; set; }
public int GameId { get; set; }
[ForeignKey("GameId")]
public int GameId { get; set; }
public GameEntity Game { get; set; }
public int PlayerId { get; set; }
[ForeignKey("PlayerId")]
public int PlayerId { get; set; }
public PlayerEntity Player { get; set; }
}
}

@ -45,26 +45,23 @@ namespace EntityFrameWorkLib
modelBuilder.Entity<CaseEntity>().HasKey(n => n.CaseId);
//Définition de la clé primaire de TurnEntity
modelBuilder.Entity<TurnEntity>().HasKey(n => n.TurnId);
//Définition de la clé primaire de ScoreEntity
modelBuilder.Entity<ScoreEntity>().HasKey(n => n.ScoreId);
//Définition du mode de generation de la clé : génération à l'insertion
modelBuilder.Entity<PlayerEntity>().Property(n => n.PlayerId).ValueGeneratedOnAdd();
modelBuilder.Entity<GameEntity>().Property(n => n.GameId).ValueGeneratedOnAdd();
modelBuilder.Entity<GrilleEntity>().Property(n => n.GrilleId).ValueGeneratedOnAdd();
modelBuilder.Entity<CaseEntity>().Property(n => n.CaseId).ValueGeneratedOnAdd();
modelBuilder.Entity<TurnEntity>().Property(n => n.TurnId).ValueGeneratedOnAdd();
modelBuilder.Entity<ScoreEntity>().Property(n => n.ScoreId).ValueGeneratedOnAdd();
//Configuration des clés primaires et étrangères pour la table Score
modelBuilder.Entity<ScoreEntity>()
.HasKey(s => s.ScoreId);
modelBuilder.Entity<GameEntity>()
.HasKey(g => g.GameId);
modelBuilder.Entity<PlayerEntity>()
.HasKey(p => p.PlayerId);
modelBuilder.Entity<ScoreEntity>()
.HasKey(s => new { s.GameId, s.PlayerId });
modelBuilder.Entity<ScoreEntity>()
.HasOne(s => s.Game)
.WithMany(g => g.Scores)
@ -72,9 +69,18 @@ namespace EntityFrameWorkLib
modelBuilder.Entity<ScoreEntity>()
.HasOne(s => s.Player)
.WithMany(p => p.Scores)
.WithMany()
.HasForeignKey(s => s.PlayerId);
// Configuration de la relation "one-to-many" entre GrilleEntity et CaseEntity
modelBuilder.Entity<GrilleEntity>()
.HasMany(g => g.Cases)
.WithOne(c => c.Grille)
.HasForeignKey(c => c.GrilleId);
//Configuration des clés primaires et étrangères pour la table Participate
base.OnModelCreating(modelBuilder);
}
}

Loading…
Cancel
Save