Model First: how to add property of type Color?

c#, ef-model-first, entity-framework

Solution

Another option here, is to use adapt the answer from Entity Framework 6 Code First - Custom Type Mapping

public class MyLittlePony {
    public string Name { get; set; }
    public Int32 Argb {
        get {
            return Color.ToArgb();
        }
        set {
            Color = Color.FromArgb(value);
        }
    }

    [NotMapped]
    public Color Color { get; set; }
}

The `NotMapped` attribute makes the entity framework not try to map the Color property to a column in the database.

Problem

I'm creating a new database with the model-first approach and I want to add a column to a table of the type `System.Drawing.Color` but I don't have this option in the properties list. Is there a way to use more data types than the ones available?

Original source

Related problems