Why we need: As you know some time we need to store JSON directly in database , Right now In SQL server there is no specific datatype available for JSON, we need to store that in nvarchar(max).
In entity framework we can get record while we select from database ,
In Model we need Json field and similar name with NotPapped properity also.
you can follow this example.
public class TableName
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; }
public string FieldJson { get; set; } //save json in this field and
[NotMapped]
public List<FieldList> FieldList // get return list from this properity
{
get => !string.IsNullOrEmpty(FieldJson) ? JsonConvert.DeserializeObject<List<FieldList>>(FieldJson) : null;
}
}
for more info you can follow this url.