title: How can I resolve .NET Core with EF Core required field error?
body: <p>I have a .NET Core (6.0.1) API that was constructed using DB first method with EF Core (6.0.1). Whenever I try to POST to a specific entity, I am getting a &quot;field is required&quot; error for one of the navigation properties in the entity. I have several other entities structured in a similar way that seem to be working fine, but this one is causing me issues and I cannot figure it out. Any ideas?</p>
  <p>From DBContext:</p>
  <pre><code>    modelBuilder.Entity&lt;InsuranceCompanyStatus&gt;(entity =&gt;
          {
              entity.HasKey(e =&gt; e.InsCoStatusId);
  
              entity.ToTable(&quot;InsuranceCompanyStatus&quot;);
  
              entity.Property(e =&gt; e.InsCoStatusId).HasColumnName(&quot;InsCoStatusID&quot;);
  
              entity.Property(e =&gt; e.InsuranceCompanyId).HasColumnName(&quot;InsuranceCompanyID&quot;);
  
              entity.Property(e =&gt; e.State)
                  .HasMaxLength(2)
                  .IsUnicode(false)
                  .IsFixedLength();
  
              entity.HasOne(d =&gt; d.InsuranceCompany)
                  .WithMany(p =&gt; p.InsuranceCompanyStatuses)
                  .HasForeignKey(d =&gt; d.InsuranceCompanyId)
                  .HasConstraintName(&quot;FK_InsuranceCompanyStatus_InsuranceCompanies&quot;);
          });
  </code></pre>
  <p>Scaffolded Model:</p>
  <pre><code>    public partial class InsuranceCompanyStatus
      {
        public int InsCoStatusId { get; set; }
        public Guid InsuranceCompanyId { get; set; }
        public string State { get; set; } = null!;
        public bool Admitted { get; set; }
        public bool? Approved { get; set; }
  
        public virtual InsuranceCompany InsuranceCompany { get; set; } = null!;
      }
  </code></pre>
  <p>JSON from Attempted POST Body:</p>
  <pre><code>    {
       &quot;insuranceCompanyId&quot;: &quot;caa3e956-a3be-4670-83e3-53a6ec47731e&quot;,
       &quot;state&quot;: &quot;AL&quot;,
       &quot;admitted&quot;: true,
       &quot;approved&quot;: true
      }
  </code></pre>
  <p>Error response status is 400:</p>
  <pre><code>    {
       &quot;type&quot;: &quot;https://tools.ietf.org/html/rfc7231#section-6.5.1&quot;,
       &quot;title&quot;: &quot;One or more validation errors occurred.&quot;,
       &quot;status&quot;: 400,
       &quot;traceId&quot;: &quot;00-cf1de6fe8e4fb67a04ff7d4c8b6a1c68-f426059123424d72-00&quot;,
       &quot;errors&quot;: {
          &quot;InsuranceCompany&quot;: [
          &quot;The InsuranceCompany field is required.&quot;
       ]
      }
      }
  </code></pre>