I saw this error, "Error: read ECONNRESET", on Postman's Console after changing my controller to insert data into the database via _context.AddRange()
. Previously, I added data via _context.Entity.Add()
and it was fine.
I changed the insertion method to be able to add a Lista (list) entity to the database while also inserting a list of n Pessoa (person) entities and n relations (list x person) to the database.
The inserts were all successfully made, although Postman still "Could not get any response".
Any idea why this is happening?
public async Task<IActionResult> PostListas(ListaFileInput input)
{
...
Listas lista = new Listas
{
OwnerId = userId,
Lista = input.Lista
};
...
List<Pessoas> pessoas = csv.GetRecords<Pessoas>().ToList();
foreach (Pessoas pessoa in pessoas)
{
pessoa.OwnerId = userId;
_context.AddRange(new ListasXPessoas() { Lista = lista, Pessoa = pessoa });
}
await _context.SaveChangesAsync();
return CreatedAtAction("GetListas", new { id = lista.ListaId }, lista);