1
Next I am creating a webapi (I am using the Entity Framework) with two classes, Course and Discipline, where the discipline has the Id of a course, I created as follows:
public class Curso
{
    public int Id { get; set; }
    public string Nome { get; set; }
    public List<Disciplina> Disciplinas{ get; set; }
}
public class Disciplina
{
    public int Id { get; set; }
    public string Nome { get; set; }
    public int CursoId { get; set; }
    public Curso Curso{ get; set; }
}
The Onmodelcreating method looks like this:
protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Disciplina>()
            .HasOne(p => p.Curso)
            .WithMany(p => p.Disciplinas)
            .HasForeignKey(p => p.CursoId);
        base.OnModelCreating(modelBuilder);
    }
In the database created right, Course has Id and Name and Discipline has Id, Name and Cursoid, but when I make the GET’s requests the result is as follows:
[
  {
    "id": 1,
    "nome": "SI",
    "disciplinas": 1,
  }
]
[
  {
    "id": 1,
    "nome": "POO",
    "cursoId": 1,
    "curso": null
  }
]
Is there any way for Entity to map better so that those keys that are coming NULL do not appear in JSON?
Remembering that I only need the course id in the discipline.
It worked out, thanks!
– Bruno Inácio