I have a class to save to database using codefirst ef, as follows

```
public class Book
{
    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int BookId { get; set; }
    public string Name { get; set; }
    public Dictionary<string, object> Properties { get; set; }
}

```

it works fine, except it does not generate any column for the Dictionary. I want it to make a varchar(max) and I want it to convert my dictionary into JSON and write the JSON string into the column.

How is the easiest way to do that? I suppose I can add a dummy string like this...

```
    public string PropertiesJson;
    public Dictionary<string, object> Properties
    {
        get { return JsonConvert.DeserializeObject<Dictionary<string, object>>(PropertiesJson); }
        set { PropertiesJson = JsonConvert.SerializeObject(value); }
    }

```

And the string will get written to the database. However this has several problems. The string might get stale if someone adds to the dictionary, and the logic isn't properly lazy, etc. 

And I want to use the paradigm for the columns in several tables, so I'd like to have a simple plug in type. For example,

```
    public PropertyDictionary Properties { get; set; }

```

in which `PropertyDictionary` is a type with which EF will automatically do the right thing. is that the best way? How can I do that?