IT:AD:EF/CodeFirst:HowTo:Work with Enums
Summary
Notes
- Enum support was introduced in EF5 (VS2012 targets it already)
- Enums can be mapped to byte, int16, int32, Int64, SByte
using System.Data.Entity;
enum Sex {Undefined, Unknown, Male, Female}
public Person {
Sex Sex {get;set;}
}
Done. Works as one would expect. Saves to a db table with an int or byte column. Transparent.