title: BlazorWebAssembly GetFromJsonAsync Not Serialize Child Collection
body: <p>the question is, why when i call  a api from client side with HttClient .GetFromJsonAsync the entity dont have the child collection?. I call the api from browser and the JSON text have the collections, but on object not.</p>
  <p>this is the code of my entities:</p>
  <pre><code>using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations.Schema;
  
  namespace excelnobleza.shared.Models.Tablas.Produccion
  {
      [Table(&quot;Lineas&quot;)]
      public class Linea
      {
          public int Id { get; set; }
          public string Nombre { get; set; }
          public string Responsable { get; set; }
          public string EmailResponsable { get; set; }
          public virtual ICollection&lt;Maquina&gt; Maquinas { get; } = new HashSet&lt;Maquina&gt;();
          public override string ToString() =&gt; this.Nombre;
      }
  
      public class Maquina
      {
          public int Id { get; set; }
  
          [Required(ErrorMessage = &quot;El nombre de la Maquina es requerido&quot;)]
          public string NombreMaquina { get; set; }
  
          [Required(ErrorMessage = &quot;La Linea a la que pertenece la maquina es requerida&quot;)]
          [ForeignKey(&quot;Linea&quot;)]
          public int? Linea_Id { get; set; }
          
          public virtual Linea Linea { get; set; }
      }
  }
  </code></pre>
  <p>and i create a controller for API, the code for return all is:</p>
  <pre><code>    // GET: api/Lineas
      [HttpGet]
      public async Task&lt;ActionResult&lt;Linea[]&gt;&gt; GetLineas()
      {
          return await _context.Lineas.Include(o=&gt; o.Maquinas).ToArrayAsync();
      }
  </code></pre>
  <p>this return the JSON like:</p>
  <pre><code>   [
     {
        &quot;Id&quot;:1,
        &quot;Nombre&quot;:&quot;SCHIAVI&quot;,
        &quot;Responsable&quot;:&quot;JOSUE TORRES&quot;,
        &quot;EmailResponsable&quot;:&quot;jtorres&quot;,
        &quot;Maquinas&quot;:[
           {
              &quot;Id&quot;:1,
              &quot;NombreMaquina&quot;:&quot;SCHIAVI&quot;,
              &quot;ModeloMaquina&quot;:null,
              &quot;TipoMaquina_Id&quot;:1,
              &quot;TipoMaquina&quot;:null,
              &quot;Linea_Id&quot;:1
           },
           {
              &quot;Id&quot;:2,
              &quot;NombreMaquina&quot;:&quot;Titan 1&quot;,
              &quot;ModeloMaquina&quot;:null,
              &quot;TipoMaquina_Id&quot;:3,
              &quot;TipoMaquina&quot;:null,
              &quot;Linea_Id&quot;:1
           },
           {
              &quot;Id&quot;:3,
              &quot;NombreMaquina&quot;:&quot;Simplex&quot;,
              &quot;ModeloMaquina&quot;:null,
              &quot;TipoMaquina_Id&quot;:2,
              &quot;TipoMaquina&quot;:null,
              &quot;Linea_Id&quot;:1
           },
           {
              &quot;Id&quot;:4,
              &quot;NombreMaquina&quot;:&quot;Brazileña&quot;,
              &quot;ModeloMaquina&quot;:null,
              &quot;TipoMaquina_Id&quot;:8,
              &quot;TipoMaquina&quot;:null,
              &quot;Linea_Id&quot;:1
           }
        ]
     },
     {
        &quot;Id&quot;:2,
        &quot;Nombre&quot;:&quot;WINDMOLLER&quot;,
        &quot;Responsable&quot;:&quot;ERASMO CARRASCO&quot;,
        &quot;EmailResponsable&quot;:&quot;ecarrasco&quot;,
        &quot;Maquinas&quot;:[
           {
              &quot;Id&quot;:5,
              &quot;NombreMaquina&quot;:&quot;WINDMOLLER&quot;,
              &quot;ModeloMaquina&quot;:null,
              &quot;TipoMaquina_Id&quot;:1,
              &quot;TipoMaquina&quot;:null,
              &quot;Linea_Id&quot;:2
           },
           {
              &quot;Id&quot;:6,
              &quot;NombreMaquina&quot;:&quot;TITAN 2&quot;,
              &quot;ModeloMaquina&quot;:null,
              &quot;TipoMaquina_Id&quot;:3,
              &quot;TipoMaquina&quot;:null,
              &quot;Linea_Id&quot;:2
           },
           {
              &quot;Id&quot;:17,
              &quot;NombreMaquina&quot;:&quot;Super Simplex&quot;,
              &quot;ModeloMaquina&quot;:null,
              &quot;TipoMaquina_Id&quot;:2,
              &quot;TipoMaquina&quot;:null,
              &quot;Linea_Id&quot;:2
           }
        ]
     }
  ]
  </code></pre>
  <p>and the RazorCode is:</p>
  <pre><code>@page &quot;/lineas&quot;
  @inject HttpClient client
  @inject IJSRuntime js
  @using excelnobleza.shared.Models.Tablas.Produccion 
  
  &lt;h3&gt;Lineas&lt;/h3&gt;
  &lt;div class=&quot;form-group&quot;&gt;
    &lt;a class=&quot;btn btn-success&quot; href=&quot;lineas/create&quot;&gt;&lt;i class=&quot;oi oi-plus&quot;&gt;&lt;/i&gt; Crear&lt;/a&gt;
  &lt;/div&gt;
  @if (Lineas == null)
  {
    &lt;h3&gt;Loading...&lt;/h3&gt;
  }
  else if (Lineas.Length == 0)
  {
    &lt;h3&gt;No se encontraron&lt;/h3&gt;
  }
  else
  {
    &lt;table class=&quot;table table-striped&quot;&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;Id&lt;/th&gt;
          &lt;th&gt;Nombre&lt;/th&gt;
          &lt;th&gt;Responsable&lt;/th&gt;
          &lt;th&gt;Email Responsable&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        @foreach (Linea lin_ in Lineas)
        {
          &lt;tr&gt;
            &lt;td&gt;@lin_.Id&lt;/td&gt;
            &lt;td&gt;@lin_.Nombre&lt;/td&gt;
            &lt;td&gt;@lin_.Responsable&lt;/td&gt;
            &lt;td&gt;    
              @foreach (Maquina maq in lin_.Maquinas)
              {
                &lt;h4&gt;@maq.NombreMaquina - @maq.ModeloMaquina&lt;/h4&gt;
              }
            &lt;/td&gt;    
            &lt;td&gt;
              &lt;a class=&quot;btn btn-success&quot; href=&quot;lineas/edit/@lin_.Id&quot;&gt;Edit&lt;/a&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
        }
      &lt;/tbody&gt;
    &lt;/table&gt;
  }
  
  @code {
      Linea[] Lineas;    
  
      protected override async Task OnInitializedAsync()
      {
        Console.WriteLine(&quot;getting Lineas...&quot;);
        Lineas = await client.GetFromJsonAsync&lt;Linea[]&gt;(&quot;api/lineas&quot;);
  
        Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(Lineas));// in this line i try to see the object string, but not have the collection
      }
  }
  </code></pre>
  <p>But the &quot;lin_&quot; object  not show the collection of &quot;Maquinas&quot;. :(</p>
  <blockquote>
  <p><em>Edited</em> - <strong>the problem has been solved</strong>
  <em>on entity change the Icollection to List and set to not readonly property</em></p>
  </blockquote>
  <pre><code>    [Table(&quot;Lineas&quot;)]
      public class Linea
      {
          public int Id { get; set; }
          public string Nombre { get; set; }
          public string Responsable { get; set; }
          public string EmailResponsable { get; set; }
          public virtual List&lt;Maquina&gt; Maquinas { get; set; } = new List&lt;Maquina&gt;();
          public override string ToString() =&gt; this.Nombre;
      }
  </code></pre>