From 509b0d75650b9bf099976d564f0199e932b33734 Mon Sep 17 00:00:00 2001 From: clchieu Date: Tue, 2 Apr 2024 18:07:15 +0200 Subject: [PATCH] =?UTF-8?q?V=C3=A9rification=20production?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index f4e19f8..a12b0d1 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -37,7 +37,14 @@ builder.Services.AddScoped, SuccessDataServiceApi>() builder.Services.AddScoped, LessonDataService>(); builder.Services.AddScoped, LessonDataServiceApi>(); -builder.Services.AddDbContext(); +builder.Services.AddDbContext(options => +{ + if (builder.Environment.IsProduction()) + { + throw new Exception("I am in production mode"); + } + throw new Exception("I am in development mode"); +}); builder.Services.AddDbContext(options => options.UseInMemoryDatabase("appDb")); builder.Services.AddIdentityApiEndpoints().AddEntityFrameworkStores();