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);