In my web application I use a model with an Enum property. For example:
public class SomeObject
{
public Guid ID { get; set; }
public string Name { get; set; }
public Color Color { get; set; }
}
public enum Color
{
blue,
red
}
Color is a required field form. Using EF Core based on that model created a table where the Color column not null.
However, some of the historic data I'm trying to import into the table does null values for Color.
From the design stand point, what should be a better solution:
- Change the model to make Color nullable and add extra validation on the UI and inside APIs to prevent null values.
- Add null value to Enum itself.
- Assign some default value to the imported data with null Color.
I don't like any of these options, but what would be the best one in terms of design?
Aucun commentaire:
Enregistrer un commentaire