I'm doing some tests to take a project. I have been working with ASP.NET Core MVC and Entity Framework relatively recently. I have a simple database in SQL Server to prove how it is:
In the test project I have a controller TestController; the code is this:
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using WEBAPPHTTP.Models;
namespace WEBAPPHTTP.Controllers
{
[Route ("api/controller[]")]
public class TestController: Controller
{
[HttpGet("/api/values")]
public IEnumerable<string> Get()
{
using (TareasContext db = new TareasContext())
{
var listar = db.Tareas;
var n = listar.Count();
string[] array = new string[n+1];
int i = 0;
foreach (var otareas in listar)
{
array[i] = otareas.Tarea.ToString();
i = i++;
}
return array;
}
}
}
}
Obviously I'm doing something wrong but the output is this:
in localhost/api/values:
["ahora",null,null,null,null]
It only shows me the last record of the database followed by a few NULL, this test the idea is that all the results are loaded in the array.
I'm sure it's a very early mistake, I hope you can guide me.

i = i++;looks very strange and wrong. You assignitoiand then incrementi.