I am using EF4.3.1 and MVC4 code first.
My database is being created except for one column and no error is given.
Why would this column not be created?
Should I be using the EnumDataType attribute (it doesn’t seem to do anything)?
public class Setting
{
public Guid SettingId { get; set; }
public string Key { get; set; }
public string Value { get; set; }
[Column("DataType", TypeName = "varchar")]
public SettingDataType DataType { get; set; }
}
public enum SettingDataType
{
[Description("String")]
text,
[Description("Integer")]
integer,
[Description("Boolean")]
boolean
}
Enums are still not supported in EF 4.3. It does not make a difference whether you specify another DataType in the attribute.
Enums are simply completely ignored by EF when analyzing the class and generating the tables.
Enumsupport is promised for EF 5.0 though … finally!For now use an
intProperty instead and add another Property that casts theintto theenumvalue on the fly. Also just to be sure nothing breaks with the next EF version add theIgnorekeyword.