With entity framework 5.0 onwards, you can simply use the enumeration:
namespace MyProject.Entities { public enum ReasonOfVisit { NotSet = 0, For business reason = 1, For control = 2, For lefting package = 3, For leisure = 4 } public class Visitor { ... public ReasonOfVisit ReasonOfVisit { get; set; } ... } }
If you use EF <5.0, you can use a property of type enum mapped to the byte / int property
public class Visitor { ... public byte ReasonOfVisitAsByte { get; set; } public ReasonOfVisit ReasonOfVisit { get { return (ReasonOfVisit)ReasonOfVisitAsByte; } set { ReasonOfVisitAsByte = (byte)value; } } ... }
PS As for your questions:
What will be the data type of the enumeration values
EF is likely to use int type
How to define string values ββin this enumeration
You cannot use strings directly, but if you use attributes and make extra efforts, you can set the enumeration to return a string directly, not its int value. You can read about it here.
source share