3 Commits 1089996603 ... 079487a2bf

Auteur SHA1 Bericht Datum
  Florian Morel 079487a2bf issue with tracking solved 1 jaar geleden
  Florian Morel a2f0e2ec89 fix DbContextInitializer STruct 1 jaar geleden
  Florian Morel 6113c54d3b change the way DBcontext is initialized 1 jaar geleden

+ 6 - 6
Dotnet/DataLayer/AbstractRepository.cs

@@ -7,6 +7,12 @@ namespace DataLayer;
 
 public class AbstractRepository<T> : IAbstractRepository<T> where T : BaseEntity
 {
+    public AbstractRepository(DeathwatchDbContext deathwatchDbContext)
+    {
+        _deathwatchDbContext = deathwatchDbContext;
+        _entities = _deathwatchDbContext.Set<T>();
+    }
+
     #region Fields
 
     private readonly DeathwatchDbContext _deathwatchDbContext;
@@ -14,12 +20,6 @@ public class AbstractRepository<T> : IAbstractRepository<T> where T : BaseEntity
 
     #endregion
 
-    public AbstractRepository(DeathwatchDbContext deathwatchDbContext)
-    {
-        _deathwatchDbContext = deathwatchDbContext;
-        _entities = _deathwatchDbContext.Set<T>();
-    }
-
     #region Public Methods
 
     public async Task<T> GetById(int id)

+ 1 - 11
Dotnet/DataLayer/DataLayer.csproj

@@ -21,14 +21,4 @@
     <ProjectReference Include="..\Domain\Domain.csproj" />
   </ItemGroup>
 
-  <ItemGroup>
-    <Folder Include="Migrations\" />
-  </ItemGroup>
-
-  <ItemGroup>
-    <None Update="XMLTEST\01 - ldb.xml">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </None>
-  </ItemGroup>
-
-</Project>
+</Project>

+ 220 - 187
Dotnet/DataLayer/DbContextInitializer.cs

@@ -2,27 +2,23 @@
 using Domain.Weapons;
 using Domain.XML_Model;
 using Infrastructure;
-using System.Collections.Generic;
+using Microsoft.EntityFrameworkCore;
+using System.Numerics;
 
 namespace DataLayer;
 
 public static class DbContextInitializer
 {
-    public static void Initialize(DeathwatchDbContext context, string filepath = null)
+    private static bool _isSeeded = false;
+    public static async Task Initialize(DeathwatchDbContext context, string? filepath = null)
     {
-        context.Database.EnsureCreated();
-
-        // Look for any students.
-        if (context.Players.Any()) return; // DB has been seeded
-
-        var weapon = new Weapon
-        {
-            At = "test",
-            Range = 30,
-            Attribute = "CT",
-            Type = "RANGE"
-        };
+        await context.Database.EnsureCreatedAsync();
+        await SeedDatabase(context, filepath);
+    }
 
+    private static async Task SeedPlayers(DeathwatchDbContext context)
+    {
+        if (context.Players.Any()) return;
         var players = new[]
         {
             new Player
@@ -37,223 +33,260 @@ public static class DbContextInitializer
                 PER = 43,
                 FM = 43,
                 SOC = 40,
-                Weapons = new List<Weapon> { weapon }
+                Weapons = new List<Weapon>
+                {
+                    new()
+                    {
+                        At = "test",
+                        Range = 30,
+                        Attribute = "CT",
+                        Type = "RANGE"
+                    }
+                }
             }
         };
-        foreach (var player in players) context.Players.Add(player);
-        context.SaveChanges();
-
-        SeedDatabase(context, filepath);
+        foreach (var player in players) await context.Players.AddAsync(player);
+        await context.SaveChangesAsync();
     }
 
-    public static void SeedDatabase(DeathwatchDbContext context, string filesPath = null)
+    public static async Task SeedDatabase(DeathwatchDbContext context, string? filesPath = null)
     {
-        // Define the paths to the XML files
-
-        //string accessoireFilePath = Path.Combine("XML", "Accessoires.xml");
-        //string ameliorationFilePath = Path.Combine("XML", "Ameliorations.xml");
-        //string extensionFilePath = Path.Combine("XML", "Extensions.xml");
-        if (!string.IsNullOrEmpty(filesPath))
-        {
-            var roots = new List<Root>();
-            try
-            {
-                // Deserialize the XML files
-                GetRootsElements(roots, filesPath);
-                ExtractFromRoot(context, roots);
-
-            }
-            catch (Exception e)
-            {
-                throw;
-            }
-        }
+        if (_isSeeded) return;
+        await SeedPlayers(context);
+
+        if (string.IsNullOrEmpty(filesPath)) return;
+        var roots = new List<Root>();
+        GetRootsElements(roots, filesPath);
+        await ExtractFromRootAsync(context, roots);
+        _isSeeded = true;
     }
 
     private static void GetRootsElements(List<Root> roots, string filesPath)
     {
         var fileExist = Directory.Exists(filesPath);
-        if (fileExist)
-        {
-            var xmlFiles = Directory.GetFiles(filesPath, "*.xml");
+        if (!fileExist) return;
+        var xmlFiles = Directory.GetFiles(filesPath, "*.xml");
 
-            foreach (var xmlFile in xmlFiles)
-            {
-                var root = XmlHelper.DeserializeXmlFile<Root>(xmlFile);
-                roots.Add(root);
-            }
-        }
+        roots.AddRange(xmlFiles.Select(XmlHelper.DeserializeXmlFile<Root>));
     }
 
-    private static void ExtractFromRoot(DeathwatchDbContext context, List<Root> roots)
+    private static async Task ExtractFromRootAsync(DeathwatchDbContext context, List<Root> roots)
     {
-        foreach (var root in roots)
+        foreach (var root in roots.OfType<Root>())
         {
-            if (root != null)
-            {
-                if (root.Extensions != null && root.Extensions != null && !context.Extensions.Any())
-                {
-                    context.Extensions.AddRange(root.Extensions);
-                    context.SaveChanges();
-                }
+            if (!context.Accessoires.Any())
+                context.Accessoires.AddRange(root.AccessoiresArmes);
+            else
+                foreach (var item in
+                         root.AccessoiresArmes.Where(item => !context.Accessoires.Any(e => e.Id == item.Id)))
+                    await context.Accessoires.AddAsync(item);
 
-                if (root.AccessoiresArmes != null && root.AccessoiresArmes != null && !context.Accessoires.Any())
-                {
-                    context.Accessoires.AddRange(root.AccessoiresArmes);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
+
+            if (!context.Améliorations.Any())
+                context.Améliorations.AddRange(root.Améliorations);
+            else
+                foreach (var item in root.Améliorations.Where(item => !context.Améliorations.Any(e => e.Id == item.Id)))
+                    await context.Améliorations.AddAsync(item);
 
-                if (root.Améliorations != null && root.Améliorations != null && !context.Améliorations.Any())
-                {
-                    context.Améliorations.AddRange(root.Améliorations);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
+
+            if (!context.Archétypes.Any())
+                context.Archétypes.AddRange(root.Archétypes);
+            else
+                foreach (var item in root.Archétypes.Where(item => !context.Archétypes.Any(e => e.Id == item.Id)))
+                    await context.Archétypes.AddAsync(item);
 
-                if (root.Archétypes != null && root.Archétypes != null && !context.Archétypes.Any())
-                {
-                    context.Archétypes.AddRange(root.Archétypes);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
+
+            if (!context.Armes.Any())
+                context.Armes.AddRange(root.Armes);
+            else
+                foreach (var item in root.Armes.Where(item => !context.Armes.Any(e => e.Id == item.Id)))
+                    await context.Armes.AddAsync(item);
 
-                if (root.Armes != null && root.Armes != null && !context.Armes.Any())
-                {
-                    context.Armes.AddRange(root.Armes);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
+
+            if (!context.Armures.Any())
+                context.Armures.AddRange(root.Armures);
+            else
+                foreach (var item in root.Armures.Where(item => !context.Armures.Any(e => e.Id == item.Id)))
+                    await context.Armures.AddAsync(item);
 
-                if (root.Armures != null && root.Armures != null && !context.Armures.Any())
-                {
-                    context.Armures.AddRange(root.Armures);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
+
+            if (!context.Assermentations.Any())
+                context.Assermentations.AddRange(root.Assermentations);
+            else
+                foreach (var item in root.Assermentations.Where(item =>
+                             !context.Assermentations.Any(e => e.Id == item.Id)))
+                    await context.Assermentations.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Attributs.Any())
+                context.Attributs.AddRange(root.AttributsArmes);
+            else
+                foreach (var item in root.AttributsArmes.Where(item => !context.Attributs.Any(e => e.Id == item.Id)))
+                    await context.Attributs.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Carrières.Any())
+                context.Carrières.AddRange(root.Carrières);
+            else
+                foreach (var item in root.Carrières.Where(item => !context.Carrières.Any(e => e.Id == item.Id)))
+                    await context.Carrières.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Competences.Any())
+                context.Competences.AddRange(root.Competences);
+            else
+                foreach (var item in root.Competences.Where(item => !context.Competences.Any(e => e.Id == item.Id)))
+                    await context.Competences.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Coordonnées.Any())
+                context.Coordonnées.AddRange(root.Coordonnées);
+            else
+                foreach (var item in root.Coordonnées.Where(item => !context.Coordonnées.Any(e => e.Id == item.Id)))
+                    await context.Coordonnées.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Cybernétiques.Any())
+                context.Cybernétiques.AddRange(root.Cybernétiques);
+            else
+                foreach (var item in root.Cybernétiques.Where(item => !context.Cybernétiques.Any(e => e.Id == item.Id)))
+                    await context.Cybernétiques.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Disciplines.Any())
+                context.Disciplines.AddRange(root.Disciplines);
+            else
+                foreach (var item in root.Disciplines.Where(item => !context.Disciplines.Any(e => e.Id == item.Id)))
+                    await context.Disciplines.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Divinations.Any())
+                context.Divinations.AddRange(root.Divinations);
+            else
+                foreach (var item in root.Divinations.Where(item => !context.Divinations.Any(e => e.Id == item.Id)))
+                    await context.Divinations.AddAsync(item);
 
-                if (root.Assermentations != null && root.Assermentations != null && !context.Assermentations.Any())
-                {
-                    context.Assermentations.AddRange(root.Assermentations);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.AttributsArmes != null && root.AttributsArmes != null && !context.Attributs.Any())
-                {
-                    context.Attributs.AddRange(root.AttributsArmes);
-                    context.SaveChanges();
-                }
+            if (!context.Equipements.Any())
+                context.Equipements.AddRange(root.Equipements);
+            else
+                foreach (var item in root.Equipements.Where(item => !context.Equipements.Any(e => e.Id == item.Id)))
+                    await context.Equipements.AddAsync(item);
 
-                if (root.Carrières != null && root.Carrières != null && !context.Carrières.Any())
-                {
-                    context.Carrières.AddRange(root.Carrières);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Competences != null && root.Competences != null && !context.Competences.Any())
-                {
-                    context.Competences.AddRange(root.Competences);
-                    context.SaveChanges();
-                }
+            if (!context.Implants.Any())
+                context.Implants.AddRange(root.Implants);
+            else
+                foreach (var item in root.Implants.Where(item => !context.Implants.Any(e => e.Id == item.Id)))
+                    await context.Implants.AddAsync(item);
 
-                if (root.Coordonnées != null && root.Coordonnées != null && !context.Coordonnées.Any())
-                {
-                    context.Coordonnées.AddRange(root.Coordonnées);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Cybernétiques != null && root.Cybernétiques != null && !context.Cybernétiques.Any())
-                {
-                    context.Cybernétiques.AddRange(root.Cybernétiques);
+            if (!context.Mondes.Any())
+                context.Mondes.AddRange(root.Mondes);
+            else
+                foreach (var item in root.Mondes.Where(item => !context.Mondes.Any(e => e.Id == item.Id)))
+                    await context.Mondes.AddAsync(item);
 
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Disciplines != null && root.Disciplines != null && !context.Disciplines.Any())
-                {
-                    context.Disciplines.AddRange(root.Disciplines);
-                    context.SaveChanges();
-                }
+            if (!context.Mutations.Any())
+                context.Mutations.AddRange(root.Mutations);
+            else
+                foreach (var item in root.Mutations.Where(item => !context.Mutations.Any(e => e.Id == item.Id)))
+                    await context.Mutations.AddAsync(item);
 
-                if (root.Divinations != null && root.Divinations != null && !context.Divinations.Any())
-                {
-                    context.Divinations.AddRange(root.Divinations);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Equipements != null && root.Equipements != null && !context.Equipements.Any())
-                {
-                    context.Equipements.AddRange(root.Equipements);
-                    context.SaveChanges();
-                }
+            if (!context.Pouvoirs.Any())
+                context.Pouvoirs.AddRange(root.Pouvoirs);
+            else
+                foreach (var item in root.Pouvoirs.Where(item => !context.Pouvoirs.Any(e => e.Id == item.Id)))
+                    await context.Pouvoirs.AddAsync(item);
 
-                if (root.Implants != null && root.Implants != null && !context.Implants.Any())
-                {
-                    context.Implants.AddRange(root.Implants);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Mondes != null && root.Mondes != null && !context.Mondes.Any())
-                {
-                    context.Mondes.AddRange(root.Mondes);
-                    context.SaveChanges();
-                }
+            if (!context.Promotions.Any())
+                context.Promotions.AddRange(root.Promotions);
+            else
+                foreach (var item in root.Promotions.Where(item => !context.Promotions.Any(e => e.Id == item.Id)))
+                    await context.Promotions.AddAsync(item);
 
-                if (root.Mutations != null && root.Mutations != null && !context.Mutations.Any())
-                {
-                    context.Mutations.AddRange(root.Mutations);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Pouvoirs != null && root.Pouvoirs != null && !context.Pouvoirs.Any())
-                {
-                    context.Pouvoirs.AddRange(root.Pouvoirs);
-                    context.SaveChanges();
-                }
+            if (!context.Seuils.Any())
+                context.Seuils.AddRange(root.SeuilsXp);
+            else
+                foreach (var item in root.SeuilsXp.Where(item => !context.Seuils.Any(e => e.Id == item.Id)))
+                    await context.Seuils.AddAsync(item);
 
-                if (root.Promotions != null && root.Promotions != null && !context.Promotions.Any())
-                {
-                    context.Promotions.AddRange(root.Promotions);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.SeuilsXp != null && root.SeuilsXp != null && !context.Seuils.Any())
-                {
-                    context.Seuils.AddRange(root.SeuilsXp);
-                    context.SaveChanges();
-                }
+            if (!context.Sousmondes.Any())
+                context.Sousmondes.AddRange(root.Sousmondes);
+            else
+                foreach (var item in root.Sousmondes.Where(item => !context.Sousmondes.Any(e => e.Id == item.Id)))
+                    await context.Sousmondes.AddAsync(item);
 
-                if (root.Sousmondes != null && root.Sousmondes != null && !context.Sousmondes.Any())
-                {
-                    context.Sousmondes.AddRange(root.Sousmondes);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Talents != null && root.Talents != null && !context.Talents.Any())
-                {
-                    context.Talents.AddRange(root.Talents);
-                    context.SaveChanges();
-                }
+            if (!context.Traits.Any())
+                context.Traits.AddRange(root.Traits);
+            else
+                foreach (var item in root.Traits.Where(item => !context.Traits.Any(e => e.Id == item.Id)))
+                    await context.Traits.AddAsync(item);
 
-                if (root.Traits != null && root.Traits != null && !context.Traits.Any())
-                {
-                    context.Traits.AddRange(root.Traits);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
 
-                if (root.Troubles != null && root.Troubles != null && !context.Troubles.Any())
-                {
-                    context.Troubles.AddRange(root.Troubles);
-                    context.SaveChanges();
-                }
+            if (!context.Troubles.Any())
+                context.Troubles.AddRange(root.Troubles);
+            else
+                foreach (var item in root.Troubles.Where(item => !context.Troubles.Any(e => e.Id == item.Id)))
+                    await context.Troubles.AddAsync(item);
 
-                if (root.TypeMondes != null && root.TypeMondes != null && !context.TypeMondes.Any())
-                {
-                    context.TypeMondes.AddRange(root.TypeMondes);
-                    context.SaveChanges();
-                }
+            await context.SaveChangesAsync();
+
+            if (!context.TypeMondes.Any())
+                context.TypeMondes.AddRange(root.TypeMondes);
+            else
+                foreach (var item in root.TypeMondes.Where(item => !context.TypeMondes.Any(e => e.Id == item.Id)))
+                    await context.TypeMondes.AddAsync(item);
+
+            await context.SaveChangesAsync();
 
-                if (root.TypesNom != null && root.TypesNom != null && !context.TypesNom.Any())
+            if (!context.TypesNom.Any())
+                context.TypesNom.AddRange(root.TypesNom);
+            else
+                foreach (var item in root.TypesNom.Where(item => !context.TypesNom.Any(e => e.Id == item.Id)))
+                    await context.TypesNom.AddAsync(item);
+
+            await context.SaveChangesAsync();
+
+            if (!context.Talents.Any())
+                context.Talents.AddRange(root.Talents);
+            else
+                foreach (var item in root.Talents)
                 {
-                    context.TypesNom.AddRange(root.TypesNom);
-                    context.SaveChanges();
+                    if (!context.Talents.AsNoTracking().Any(e => e.Id == item.Id))
+                        await context.Talents.AddAsync(item);
+                    await context.SaveChangesAsync();
+
                 }
-            }
+
         }
     }
 }

+ 9 - 36
Dotnet/DataLayer/DeathwatchDbContext.cs

@@ -7,6 +7,15 @@ namespace DataLayer;
 
 public class DeathwatchDbContext : DbContext
 {
+
+    public DeathwatchDbContext()
+    {
+    }
+
+    public DeathwatchDbContext(DbContextOptions<DeathwatchDbContext> options) : base(options)
+    {
+    }
+
     public DbSet<Player> Players { get; set; }
     public DbSet<Weapon> Weapons { get; set; }
     public DbSet<Extension> Extensions { get; set; }
@@ -38,41 +47,6 @@ public class DeathwatchDbContext : DbContext
     public DbSet<Trouble> Troubles { get; set; }
     public DbSet<TypeMonde> TypeMondes { get; set; }
     public DbSet<TypeName> TypesNom { get; set; }
-    //public DbSet<AccessoiresArmes> AllAccessoiresArmes { get; set; }
-    //public DbSet<Améliorations> AllAméliorations { get; set; }
-    //public DbSet<Archétypes> AllArchétypes { get; set; }
-    //public DbSet<Armes> AllArmes { get; set; }
-    //public DbSet<Armures> AllArmures { get; set; }
-    //public DbSet<Assermentations> AllAssermentations { get; set; }
-    //public DbSet<AttributsArmes> AllAttributsArmes { get; set; }
-    //public DbSet<Carrières> AllCarrières { get; set; }
-    //public DbSet<Competences> AllCompetences { get; set; }
-    //public DbSet<Coordonnées> AllCoordonnées { get; set; }
-    //public DbSet<Cybernétiques> AllCybernétiques { get; set; }
-    //public DbSet<Disciplines> AllDisciplines { get; set; }
-    //public DbSet<Divinations> AllDivinations { get; set; }
-    //public DbSet<Equipements> AllEquipements { get; set; }
-    //public DbSet<Implants> AllImplants { get; set; }
-    //public DbSet<Mondes> AllMondes { get; set; }
-    //public DbSet<Mutations> AllMutations { get; set; }
-    //public DbSet<Pouvoirs> AllPouvoirs { get; set; }
-    //public DbSet<Promotions> AllPromotions { get; set; }
-    //public DbSet<SeuilsXp> AllSeuilsXp { get; set; }
-    //public DbSet<Sousmondes> AllSousmondes { get; set; }
-    //public DbSet<Talents> AllTalents { get; set; }
-    //public DbSet<Traits> AllTraits { get; set; }
-    //public DbSet<Troubles> AllTroubles { get; set; }
-    //public DbSet<TypeMondes> AllTypeMondes { get; set; }
-    //public DbSet<TypesNom> AllTypesNom { get; set; }
-
-
-    public DeathwatchDbContext() : base()
-    {
-    }
-
-    public DeathwatchDbContext(DbContextOptions<DeathwatchDbContext> options) : base(options)
-    {
-    }
 
     protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
     {
@@ -258,6 +232,5 @@ public class DeathwatchDbContext : DbContext
         //    .HasMany(t => t.TypeNom)
         //    .WithOne()
         //    .HasForeignKey(x => x.TypeNomId);
-
     }
 }

+ 0 - 167
Dotnet/DataLayer/Migrations/20230106171505_InitialCreate.Designer.cs

@@ -1,167 +0,0 @@
-// <auto-generated />
-using System;
-using DataLayer;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace DataLayer.Migrations
-{
-    [DbContext(typeof(DeathwatchDbContext))]
-    [Migration("20230106171505_InitialCreate")]
-    partial class InitialCreate
-    {
-        /// <inheritdoc />
-        protected override void BuildTargetModel(ModelBuilder modelBuilder)
-        {
-#pragma warning disable 612, 618
-            modelBuilder
-                .HasAnnotation("ProductVersion", "7.0.1")
-                .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
-            SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
-            modelBuilder.Entity("Domain.Player", b =>
-                {
-                    b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasColumnType("int");
-
-                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
-
-                    b.Property<int>("AG")
-                        .HasColumnType("int");
-
-                    b.Property<string>("Background")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("CC")
-                        .HasColumnType("int");
-
-                    b.Property<int>("CT")
-                        .HasColumnType("int");
-
-                    b.Property<string>("CharacterName")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<DateTime>("CreatedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<int>("E")
-                        .HasColumnType("int");
-
-                    b.Property<int>("Experience")
-                        .HasColumnType("int");
-
-                    b.Property<int>("F")
-                        .HasColumnType("int");
-
-                    b.Property<int>("FM")
-                        .HasColumnType("int");
-
-                    b.Property<int>("INT")
-                        .HasColumnType("int");
-
-                    b.Property<int>("MF")
-                        .HasColumnType("int");
-
-                    b.Property<DateTime>("ModifiedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<string>("Name")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("PER")
-                        .HasColumnType("int");
-
-                    b.Property<int>("SOC")
-                        .HasColumnType("int");
-
-                    b.HasKey("Id");
-
-                    b.ToTable("Players");
-                });
-
-            modelBuilder.Entity("Domain.Weapons.Weapon", b =>
-                {
-                    b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasColumnType("int");
-
-                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
-
-                    b.Property<string>("At")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<string>("Attribute")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<DateTime>("CreatedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<string>("GPE")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<string>("Mode")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<DateTime>("ModifiedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<string>("Name")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("Pene")
-                        .HasColumnType("int");
-
-                    b.Property<int>("Range")
-                        .HasColumnType("int");
-
-                    b.Property<string>("Rch")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<string>("Type")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.HasKey("Id");
-
-                    b.ToTable("Weapons");
-                });
-
-            modelBuilder.Entity("PlayerWeapon", b =>
-                {
-                    b.Property<int>("PlayersId")
-                        .HasColumnType("int");
-
-                    b.Property<int>("WeaponsId")
-                        .HasColumnType("int");
-
-                    b.HasKey("PlayersId", "WeaponsId");
-
-                    b.HasIndex("WeaponsId");
-
-                    b.ToTable("PlayerWeapon");
-                });
-
-            modelBuilder.Entity("PlayerWeapon", b =>
-                {
-                    b.HasOne("Domain.Player", null)
-                        .WithMany()
-                        .HasForeignKey("PlayersId")
-                        .OnDelete(DeleteBehavior.Cascade)
-                        .IsRequired();
-
-                    b.HasOne("Domain.Weapons.Weapon", null)
-                        .WithMany()
-                        .HasForeignKey("WeaponsId")
-                        .OnDelete(DeleteBehavior.Cascade)
-                        .IsRequired();
-                });
-#pragma warning restore 612, 618
-        }
-    }
-}

+ 0 - 108
Dotnet/DataLayer/Migrations/20230106171505_InitialCreate.cs

@@ -1,108 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace DataLayer.Migrations
-{
-    /// <inheritdoc />
-    public partial class InitialCreate : Migration
-    {
-        /// <inheritdoc />
-        protected override void Up(MigrationBuilder migrationBuilder)
-        {
-            migrationBuilder.CreateTable(
-                name: "Players",
-                columns: table => new
-                {
-                    Id = table.Column<int>(type: "int", nullable: false)
-                        .Annotation("SqlServer:Identity", "1, 1"),
-                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    CharacterName = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    Background = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    Experience = table.Column<int>(type: "int", nullable: false),
-                    CC = table.Column<int>(type: "int", nullable: false),
-                    CT = table.Column<int>(type: "int", nullable: false),
-                    F = table.Column<int>(type: "int", nullable: false),
-                    E = table.Column<int>(type: "int", nullable: false),
-                    AG = table.Column<int>(type: "int", nullable: false),
-                    INT = table.Column<int>(type: "int", nullable: false),
-                    PER = table.Column<int>(type: "int", nullable: false),
-                    FM = table.Column<int>(type: "int", nullable: false),
-                    SOC = table.Column<int>(type: "int", nullable: false),
-                    MF = table.Column<int>(type: "int", nullable: false),
-                    CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
-                    ModifiedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
-                },
-                constraints: table =>
-                {
-                    table.PrimaryKey("PK_Players", x => x.Id);
-                });
-
-            migrationBuilder.CreateTable(
-                name: "Weapons",
-                columns: table => new
-                {
-                    Id = table.Column<int>(type: "int", nullable: false)
-                        .Annotation("SqlServer:Identity", "1, 1"),
-                    Range = table.Column<int>(type: "int", nullable: false),
-                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    GPE = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    Type = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    Pene = table.Column<int>(type: "int", nullable: false),
-                    Mode = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    At = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    Rch = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    Attribute = table.Column<string>(type: "nvarchar(max)", nullable: true),
-                    CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
-                    ModifiedDate = table.Column<DateTime>(type: "datetime2", nullable: false)
-                },
-                constraints: table =>
-                {
-                    table.PrimaryKey("PK_Weapons", x => x.Id);
-                });
-
-            migrationBuilder.CreateTable(
-                name: "PlayerWeapon",
-                columns: table => new
-                {
-                    PlayersId = table.Column<int>(type: "int", nullable: false),
-                    WeaponsId = table.Column<int>(type: "int", nullable: false)
-                },
-                constraints: table =>
-                {
-                    table.PrimaryKey("PK_PlayerWeapon", x => new { x.PlayersId, x.WeaponsId });
-                    table.ForeignKey(
-                        name: "FK_PlayerWeapon_Players_PlayersId",
-                        column: x => x.PlayersId,
-                        principalTable: "Players",
-                        principalColumn: "Id",
-                        onDelete: ReferentialAction.Cascade);
-                    table.ForeignKey(
-                        name: "FK_PlayerWeapon_Weapons_WeaponsId",
-                        column: x => x.WeaponsId,
-                        principalTable: "Weapons",
-                        principalColumn: "Id",
-                        onDelete: ReferentialAction.Cascade);
-                });
-
-            migrationBuilder.CreateIndex(
-                name: "IX_PlayerWeapon_WeaponsId",
-                table: "PlayerWeapon",
-                column: "WeaponsId");
-        }
-
-        /// <inheritdoc />
-        protected override void Down(MigrationBuilder migrationBuilder)
-        {
-            migrationBuilder.DropTable(
-                name: "PlayerWeapon");
-
-            migrationBuilder.DropTable(
-                name: "Players");
-
-            migrationBuilder.DropTable(
-                name: "Weapons");
-        }
-    }
-}

+ 0 - 164
Dotnet/DataLayer/Migrations/DeathwatchDbContextModelSnapshot.cs

@@ -1,164 +0,0 @@
-// <auto-generated />
-using System;
-using DataLayer;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace DataLayer.Migrations
-{
-    [DbContext(typeof(DeathwatchDbContext))]
-    partial class DeathwatchDbContextModelSnapshot : ModelSnapshot
-    {
-        protected override void BuildModel(ModelBuilder modelBuilder)
-        {
-#pragma warning disable 612, 618
-            modelBuilder
-                .HasAnnotation("ProductVersion", "7.0.1")
-                .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
-            SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
-            modelBuilder.Entity("Domain.Player", b =>
-                {
-                    b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasColumnType("int");
-
-                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
-
-                    b.Property<int>("AG")
-                        .HasColumnType("int");
-
-                    b.Property<string>("Background")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("CC")
-                        .HasColumnType("int");
-
-                    b.Property<int>("CT")
-                        .HasColumnType("int");
-
-                    b.Property<string>("CharacterName")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<DateTime>("CreatedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<int>("E")
-                        .HasColumnType("int");
-
-                    b.Property<int>("Experience")
-                        .HasColumnType("int");
-
-                    b.Property<int>("F")
-                        .HasColumnType("int");
-
-                    b.Property<int>("FM")
-                        .HasColumnType("int");
-
-                    b.Property<int>("INT")
-                        .HasColumnType("int");
-
-                    b.Property<int>("MF")
-                        .HasColumnType("int");
-
-                    b.Property<DateTime>("ModifiedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<string>("Name")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("PER")
-                        .HasColumnType("int");
-
-                    b.Property<int>("SOC")
-                        .HasColumnType("int");
-
-                    b.HasKey("Id");
-
-                    b.ToTable("Players");
-                });
-
-            modelBuilder.Entity("Domain.Weapons.Weapon", b =>
-                {
-                    b.Property<int>("Id")
-                        .ValueGeneratedOnAdd()
-                        .HasColumnType("int");
-
-                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
-
-                    b.Property<string>("At")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<string>("Attribute")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<DateTime>("CreatedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<string>("GPE")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<string>("Mode")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<DateTime>("ModifiedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<string>("Name")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("Pene")
-                        .HasColumnType("int");
-
-                    b.Property<int>("Range")
-                        .HasColumnType("int");
-
-                    b.Property<string>("Rch")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<string>("Type")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.HasKey("Id");
-
-                    b.ToTable("Weapons");
-                });
-
-            modelBuilder.Entity("PlayerWeapon", b =>
-                {
-                    b.Property<int>("PlayersId")
-                        .HasColumnType("int");
-
-                    b.Property<int>("WeaponsId")
-                        .HasColumnType("int");
-
-                    b.HasKey("PlayersId", "WeaponsId");
-
-                    b.HasIndex("WeaponsId");
-
-                    b.ToTable("PlayerWeapon");
-                });
-
-            modelBuilder.Entity("PlayerWeapon", b =>
-                {
-                    b.HasOne("Domain.Player", null)
-                        .WithMany()
-                        .HasForeignKey("PlayersId")
-                        .OnDelete(DeleteBehavior.Cascade)
-                        .IsRequired();
-
-                    b.HasOne("Domain.Weapons.Weapon", null)
-                        .WithMany()
-                        .HasForeignKey("WeaponsId")
-                        .OnDelete(DeleteBehavior.Cascade)
-                        .IsRequired();
-                });
-#pragma warning restore 612, 618
-        }
-    }
-}

+ 0 - 11
Dotnet/DataLayer/XMLTEST/01 - ldb.xml

@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<root>
-  <extensions>
-    <extension id="dh01" nom="livre de base"/>
-  </extensions>
-  <améliorations>
-    <amélioration id="01-amel2431" catégorie="technoprêtre" souscatégorie="magos explorator" promotion="8" type="compétence" nom="expression artistique (musicien)" cout="300" nb_max_ou_rang="1" />
-    <amélioration id="01-amel2432" catégorie="technoprêtre" souscatégorie="magos explorator" promotion="8" type="compétence" nom="marchandage" cout="300" nb_max_ou_rang="2" />
-  </améliorations>
-</root>

+ 2 - 2
Dotnet/Deathwatch/Deathwatch.csproj.user

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
-    <ActiveDebugProfile>Container (Dockerfile)</ActiveDebugProfile>
+    <ActiveDebugProfile>IIS Express</ActiveDebugProfile>
     <RazorPage_SelectedScaffolderID>RazorPageScaffolder</RazorPage_SelectedScaffolderID>
     <RazorPage_SelectedScaffolderCategoryPath>root/Common/RazorPage</RazorPage_SelectedScaffolderCategoryPath>
-    <NameOfLastUsedPublishProfile>C:\Users\FlorianMorel\Source\Repos\Warhammer\Dotnet\Deathwatch\Properties\PublishProfiles\deathwatchweb - Web Deploy.pubxml</NameOfLastUsedPublishProfile>
+    <NameOfLastUsedPublishProfile>deathwatchweb - Web Deploy</NameOfLastUsedPublishProfile>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
     <DebuggerFlavor>ProjectDebugger</DebuggerFlavor>

+ 6 - 3
Dotnet/Deathwatch/Program.cs

@@ -11,7 +11,10 @@ builder.Services.AddRazorPages();
 builder.Services.AddServerSideBlazor();
 
 builder.Services.AddDbContext<DeathwatchDbContext>(options =>
-    options.UseInMemoryDatabase("InMemoryDb"));
+{
+    options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
+    options.UseInMemoryDatabase("InMemoryDb");
+});
 
 builder.Services.AddTransient(typeof(IAbstractRepository<>), typeof(AbstractRepository<>));
 builder.Services.AddTransient<IPlayerService, PlayerService>();
@@ -30,9 +33,9 @@ using (var scope = scopeFactory.CreateScope())
     //var folderPath = Path.Combine($"{directory}", "Dotnet", "Deathwatch", "XML");
     var folderPath = Path.Combine($"{directory}", "XML");
     var db = scope.ServiceProvider.GetRequiredService<DeathwatchDbContext>();
-    if (db.Database.EnsureCreated())
+    if (await db.Database.EnsureCreatedAsync())
     {
-        DbContextInitializer.Initialize(db, folderPath);
+       await DbContextInitializer.Initialize(db, folderPath);
     }
 }
 

+ 12 - 0
Dotnet/Services/DiceService.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Services
+{
+    public class DiceService
+    {
+    }
+}