79757786

Date: 2025-09-06 20:47:33
Score: 1.5
Natty:
Report link

Проверьте правильно ли написано ConnectionStrings в appsettings.json (не ConnectionString).

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=localhost;Port=5432;Database=BulletinBoard;Username=postgres;Password=ДофигаСложныйПароль"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"

}

У меня в di в качестве строки подключения передавался null при инициализации контекста, но при этом обращения к нему при обычных запросах проходили (хз почему).

public static IServiceCollection RegistrarAppContexsts(this IServiceCollection services, IConfiguration configuration)
{

    services.AddDbContext<BulletinContext>(options =>
    {
        options.UseNpgsql(
            configuration.GetConnectionString("DefaultConnection"),
            b => b.MigrationsAssembly("BulletinBoard.Infrastructure.DataAccess")
        );
    });

    return services;
}

В общем будьте внимательны, не будьте как я.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • No latin characters (1.5):
  • Low reputation (1):
Posted by: Pavel200-7