title: JSON patch not working with abstract classes (inheritance)
body: <p>I am trying to use JSON patch in my .net core project to update data. I am using <strong>Table-per-type</strong> in my architecture for this particular feature.</p>
  <p>So my models are like this.</p>
  <p>I have a <strong>form</strong> model</p>
  <pre><code>public class HrFormV1
  {
      public HrFormV1()
      {
          ...
          
      }
  
      public HrFormV1(HrFormV1DTO form)
      {
          ...
      }
  
      public string Id { get; set; }
      public string Name { get; set; }
      public string Description { get; set; }
      public string OrganizationId { get; set; }
      public Organizations Organization { get; set; }
  
      public List&lt;HrFormSectionV1&gt; FormSections { get; set; }
  
      public DateTime Created { get; set; }
      public DateTime Updated { get; set; }
      public HrFormType Type { get; set; }
      public string CreatedById { get; set; }
      public User CreatedBy { get; set; }
  
      public static void DefineDbModel(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;HrFormV1&gt;().Property(f =&gt; f.Id).ValueGeneratedOnAdd();
      }
  }
  </code></pre>
  <p>Each form can have multiple sections.</p>
  <pre><code>public class HrFormSectionV1
  {
      public string Id { get; set; }
      public int Index { get; set; }
      public string FormId { get; set; }
      public HrFormV1 Form { get; set; }
  
      public HrFormSectionV1()
      {
         ...
      }
  
      public HrFormSectionV1(HrFormSectionV1DTO section)
      {
          ...
          BuildingComponents = section.BuildingComponents.Select(b =&gt; @switch[b.GetType()](b)).ToList();
      }
  
      public ICollection&lt;HrBuildingComponentsV1&gt; BuildingComponents { get; set; }
  
      public static void DefineDbModel(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;HrFormSectionV1&gt;(entity =&gt;
          {
              entity.Property(e =&gt; e.Id).ValueGeneratedOnAdd();
          });
      }
  
      private static readonly Dictionary&lt;Type, Func&lt;HrBuildingComponentV1DTO,HrBuildingComponentsV1&gt;&gt; @switch = new Dictionary&lt;Type, Func&lt;HrBuildingComponentV1DTO,HrBuildingComponentsV1&gt;&gt; {
          { typeof(HrTextBuildingComponentV1DTO), b =&gt; new HrTextBuildingComponentV1((HrTextBuildingComponentV1DTO)b) },
      };
  }
  </code></pre>
  <p>Each section can have multiple <strong>components</strong>. The thing is that components can be of multiple types like text, textarea etc.</p>
  <p>So I have created an abstract component class like this</p>
  <pre><code>{
      public abstract class HrBuildingComponentsV1
      {
          public HrBuildingComponentsV1() { }
          public HrBuildingComponentsV1(HrBuildingComponentV1DTO buildingComponent)
          {
              Id = buildingComponent.Id;
              Label = buildingComponent.Label;
              Type = buildingComponent.Type;
              Index = buildingComponent.Index;
              IsFilter = buildingComponent.IsFilter;
              SectionId = buildingComponent.SectionId;
          }
  
          public string Id { get; set; }
          public string Label { get; set; }
          public BuildingComponentType Type { get; set; }
          public int? Index { get; set; }
          public bool IsFilter { get; set; }
          public string SectionId { get; set; }
          public HrFormSectionV1 Section { get; set; }
      }
  
      public enum BuildingComponentType
      {
          ...
      }
  }
  </code></pre>
  <p>and then each component can inherit from that class, for example <strong>text</strong></p>
  <pre><code>public class HrTextBuildingComponentV1 : HrBuildingComponentsV1
  {
      public string Value { get; set; }
  
      public HrTextBuildingComponentV1() : base() { }
      public HrTextBuildingComponentV1(HrTextBuildingComponentV1DTO buildingComponentdto) 
          : base(buildingComponentdto) {
          Value = buildingComponentdto.Value;
      }
  
      public static void DefineDbModel(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;HrTextBuildingComponentV1&gt;().ToTable(&quot;HrTextBuildingComponentV1&quot;);
      }
  }
  </code></pre>
  <p>Now the issue is that when applying json patch I am not sure how to do it.</p>
  <p>If I send this</p>
  <pre><code>[{
          &quot;op&quot;: &quot;add&quot;,
          &quot;path&quot;: &quot;/formsections/0/buildingcomponents/-&quot;,
          &quot;value&quot;: {
              &quot;sectionid&quot;: &quot;section_id&quot;,
              &quot;id&quot;: &quot;ID&quot;,
              &quot;type&quot;: 0,
              &quot;label&quot;: &quot;Text&quot;,
              &quot;index&quot;: 0,
              &quot;isFilter&quot;: false,
              &quot;value&quot;:&quot;Yoo&quot;
          }
  }]
  </code></pre>
  <p>I get error saying</p>
  <blockquote>
  <p>The value '{   &quot;sectionid&quot;: &quot;section_id&quot;,   &quot;id&quot;: &quot;ID&quot;,   &quot;type&quot;: 0,<br />
  &quot;label&quot;: &quot;Text&quot;,   &quot;index&quot;: 0,   &quot;isFilter&quot;: false,   &quot;value&quot;: &quot;Yoo&quot;
  }' is invalid for target location.</p>
  </blockquote>
  <p>Any help would be highly appreciated.</p>