Let me explain : I have a .net core 3.0 API connected to a postgres database. I would like to perform basic CRUD operations with this API. I use swagger to display webrequest. Once I have created my context I migrate to the database which works very well however, as soon as I want to interact with my created table I have these errors that appears :
![NpgsqlException : Exception while connecting ]2
The application is based on a docker container. (docker compose).
Connection to the database :
My controller :
[Route("api/[controller]")]
[ApiController]
public class CatalogueController : ControllerBase
{
private readonly CatalogueContext _context;
public CatalogueController(CatalogueContext context)
{
_context = context;
}
[HttpGet]
public ActionResult<IEnumerable<Article>> GetCatalogue()
{
return _context.Article.ToList();
}
}
My Context :
public class CatalogueContext : DbContext
{
public CatalogueContext(DbContextOptions<CatalogueContext> options) : base(options)
{
}
public DbSet<Article> Article { get; set; }
}
My Table Article on my database (I use DBeaver) :