diff --git a/Sources/EFLol/ChampionContext.cs b/Sources/EFLol/ChampionContext.cs index 813108d..4a2654d 100644 --- a/Sources/EFLol/ChampionContext.cs +++ b/Sources/EFLol/ChampionContext.cs @@ -11,9 +11,20 @@ namespace EFLol { public DbSet Champions { get; set; } + public ChampionContext() + { } + + public ChampionContext(DbContextOptions options) + : base(options) + { } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlite("Data Source=loldb.db"); + if (!optionsBuilder.IsConfigured) + { + //optionsBuilder.UseSqlServer("Data Source=loldb.db"); + optionsBuilder.UseSqlite("Data Source=loldb.db"); + } } } } diff --git a/Sources/EFLol/EFLol.csproj b/Sources/EFLol/EFLol.csproj index c55d3a4..740e3bf 100644 --- a/Sources/EFLol/EFLol.csproj +++ b/Sources/EFLol/EFLol.csproj @@ -16,6 +16,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Sources/EFLol/Program.cs b/Sources/EFLol/Program.cs index 38f62aa..47f659d 100644 --- a/Sources/EFLol/Program.cs +++ b/Sources/EFLol/Program.cs @@ -1,6 +1,6 @@ using EFLol; -ChampionEntity Zeus = new ChampionEntity +/*ChampionEntity Zeus = new ChampionEntity { Name = "Zeus", Bio = "Zeus is the king of the gods." @@ -11,8 +11,27 @@ using (var context = new ChampionContext()) Console.WriteLine("Adding Zeus to the database..."); context.Champions.Add(Zeus); context.SaveChanges(); -} - +}*/ +ChampionEntity chewie = new ChampionEntity { Name = "Chewbacca", Bio = "Zeus is the king of the gods." }; +ChampionEntity yoda = new ChampionEntity { Name = "Yoda", Bio = "Zeus is the king of the gods." }; +ChampionEntity ewok = new ChampionEntity { Name = "Ewok" , Bio = "Zeus is the king of the gods." }; +using (var context = new ChampionContext()) +{ + // Crée des nounours et les insère dans la base + Console.WriteLine("Creates and inserts new Nounours"); + context.Add(chewie); + context.Add(yoda); + context.Add(ewok); + context.SaveChanges(); +} +using (var context = new ChampionContext()) +{ + foreach (var n in context.Champions) + { + Console.WriteLine($"{n.Id} - {n.Name}"); + } + context.SaveChanges(); +} \ No newline at end of file diff --git a/Sources/Model/Model.csproj b/Sources/Model/Model.csproj index 89f6363..63fa530 100644 --- a/Sources/Model/Model.csproj +++ b/Sources/Model/Model.csproj @@ -12,6 +12,14 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/Sources/Shared/Shared.csproj b/Sources/Shared/Shared.csproj index 132c02c..000356c 100644 --- a/Sources/Shared/Shared.csproj +++ b/Sources/Shared/Shared.csproj @@ -6,4 +6,13 @@ enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Sources/StubLib/StubLib.csproj b/Sources/StubLib/StubLib.csproj index 1b714b9..a51603e 100644 --- a/Sources/StubLib/StubLib.csproj +++ b/Sources/StubLib/StubLib.csproj @@ -6,6 +6,15 @@ enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Sources/TestUnitaireAPiLol/TestUnitaire.csproj b/Sources/TestUnitaireAPiLol/TestUnitaire.csproj index ed41633..393919a 100644 --- a/Sources/TestUnitaireAPiLol/TestUnitaire.csproj +++ b/Sources/TestUnitaireAPiLol/TestUnitaire.csproj @@ -9,6 +9,12 @@ + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Sources/Tests/ConsoleTests/ConsoleTests.csproj b/Sources/Tests/ConsoleTests/ConsoleTests.csproj index c52655b..69373bc 100644 --- a/Sources/Tests/ConsoleTests/ConsoleTests.csproj +++ b/Sources/Tests/ConsoleTests/ConsoleTests.csproj @@ -15,6 +15,12 @@ + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Sources/apiLOL/apiLOL.csproj b/Sources/apiLOL/apiLOL.csproj index 33350f8..f112330 100644 --- a/Sources/apiLOL/apiLOL.csproj +++ b/Sources/apiLOL/apiLOL.csproj @@ -7,6 +7,12 @@ + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +