From 060c5dc37f2d077848ac66dda40f247daf30fae7 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Tue, 30 Apr 2024 19:52:50 +0400 Subject: [PATCH] =?UTF-8?q?cleaning=20=D1=83=D1=81=D0=BB=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B1=D0=B5=D0=B7=20=D1=83=D1=81=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComputerHardwareStoreDBContext.cs | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs index 6b2bf5d..1c09ba6 100644 --- a/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs +++ b/ComputerHardwareStore/ComputerHardwareStoreDatabaseImplement/ComputerHardwareStoreDBContext.cs @@ -7,23 +7,20 @@ namespace ComputerHardwareStoreDatabaseImplement { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - if (optionsBuilder.IsConfigured == false) - { - //optionsBuilder.UseNpgsql(@"Host=localhost;Database=ProductBar_db;Username=postgres;Password=postgres"); // не надо >: - /* - * в program добавить: - * // получаем строку подключения из файла конфигурации - * string connection = builder.Configuration.GetConnectionString("DefaultConnection"); - * - * // добавляем контекст ApplicationContext в качестве сервиса в приложение - * builder.Services.AddDbContext(options => options.UseSqlServer(connection)); - * - * в appsettings: - * "ConnectionStrings": { - * "DefaultConnection": "Host=localhost;Database=ProductBar_db;Username=compstore;Password=compstore" - * }, - */ - } + /* + * в program добавить: + * // получаем строку подключения из файла конфигурации + * string connection = builder.Configuration.GetConnectionString("DefaultConnection"); + * + * // добавляем контекст ApplicationContext в качестве сервиса в приложение + * builder.Services.AddDbContext(options => options.UseSqlServer(connection)); + * + * в appsettings: + * "ConnectionStrings": { + * "DefaultConnection": "Host=localhost;Database=ProductBar_db;Username=compstore;Password=compstore" + * }, + */ + base.OnConfiguring(optionsBuilder); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);