diff --git a/Sources/EFLol/ChampionContext.cs b/Sources/EFLol/MyDbContext.cs similarity index 79% rename from Sources/EFLol/ChampionContext.cs rename to Sources/EFLol/MyDbContext.cs index 4a2654d..25c79ae 100644 --- a/Sources/EFLol/ChampionContext.cs +++ b/Sources/EFLol/MyDbContext.cs @@ -7,14 +7,14 @@ using Microsoft.EntityFrameworkCore; namespace EFLol { - public class ChampionContext : DbContext + public class MyDbContext : DbContext { public DbSet Champions { get; set; } - public ChampionContext() + public MyDbContext() { } - public ChampionContext(DbContextOptions options) + public MyDbContext(DbContextOptions options) : base(options) { } diff --git a/Sources/EFLol/Program.cs b/Sources/EFLol/Program.cs index 47f659d..4fd61f2 100644 --- a/Sources/EFLol/Program.cs +++ b/Sources/EFLol/Program.cs @@ -17,7 +17,7 @@ ChampionEntity chewie = new ChampionEntity { Name = "Chewbacca", Bio = "Zeus is 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()) +using (var context = new MyDbContext()) { // Crée des nounours et les insère dans la base Console.WriteLine("Creates and inserts new Nounours"); @@ -27,7 +27,7 @@ using (var context = new ChampionContext()) context.SaveChanges(); } -using (var context = new ChampionContext()) +using (var context = new MyDbContext()) { foreach (var n in context.Champions) { diff --git a/Sources/TestUnitaire/TestEfLol.cs b/Sources/TestUnitaire/TestEfLol.cs index e7ec753..7e506cb 100644 --- a/Sources/TestUnitaire/TestEfLol.cs +++ b/Sources/TestUnitaire/TestEfLol.cs @@ -16,12 +16,12 @@ namespace TestUnitaire var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); - var options = new DbContextOptionsBuilder() + var options = new DbContextOptionsBuilder() .UseSqlite(connection) .Options; // Act - using (var context = new ChampionContext(options)) + using (var context = new MyDbContext(options)) { await context.Database.EnsureCreatedAsync(); var Dieu = new ChampionEntity @@ -50,12 +50,12 @@ namespace TestUnitaire var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); - var options = new DbContextOptionsBuilder() + var options = new DbContextOptionsBuilder() .UseSqlite(connection) .Options; //prepares the database with one instance of the context - using (var context = new ChampionContext(options)) + using (var context = new MyDbContext(options)) { //context.Database.OpenConnection(); context.Database.EnsureCreated(); @@ -72,7 +72,7 @@ namespace TestUnitaire } //uses another instance of the context to do the tests - using (var context = new ChampionContext(options)) + using (var context = new MyDbContext(options)) { context.Database.EnsureCreated(); @@ -86,7 +86,7 @@ namespace TestUnitaire } //uses another instance of the context to do the tests - using (var context = new ChampionContext(options)) + using (var context = new MyDbContext(options)) { context.Database.EnsureCreated();