title: How to DeserializeObject from json where data model exist in Entity Framework?
body: <p>I have an incoming json object that represents the data pulled from a database structure.</p>
  
  <p>I would like to map it to the Entity Framework model which has the definitions either from attributes or from model builder in the DB context.</p>
  
  <p>When running Entity Framework, this data maps correctly so I know the models are correct.</p>
  
  <p>So using the same structure, instead of calling the database through EF, I am pulling from an API that has the same incoming data structure as the entity.Property column names. </p>
  
  <p>How do I map the incoming json structure to the model object?</p>
  
  <p><strong>Attributes</strong></p>
  
  <pre><code>[Table("model_example")]
  public class ModelExample
  {
     [Column("property_to_map")] // &lt;-- db column name
     public int PropertyToMap { get; set; }
  }
  </code></pre>
  
  <p>Or <code>ModelBuilder</code>:</p>
  
  <pre><code>modelBuilder.Entity&lt;ModelExample&gt;(entity =&gt;
  {
      entity.ToTable("model_example");
      entity.Property(e =&gt; e.PropertyToMap).HasColumnName("property_to_map");
  }
  </code></pre>
  
  <p>Incoming JSON example:</p>
  
  <pre><code> { "property_to_map":1 }   
  </code></pre>
  
  <p>So if this data was pulled from the db it would automatically be mapped to `ModelExample.PropertyToMap' and the ModelExample code model.</p>
  
  <p>How do I map it? Is there a way to use the Entity Framework process?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I know how to map from json to object using Newtonsoft. I'm trying to map to the entity without having to use a mapper. Entity Framework already has these values, I was hoping to just use entity framework tie in.</p>