Проверьте правильно ли написано 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;
}
В общем будьте внимательны, не будьте как я.