EntityFramework 学习 一 枚举
1. Convert an existing property to Enum:
using (var ctx = new SchoolDBEntities()) { Teacher tchr = new Teacher(); tchr.TeacherName = "New Teacher"; //assign enum value tchr.TeacherType = TeacherType.Permanent; ctx.Teachers.Add(tchr); ctx.SaveChanges(); }
2. Add New Enum from Designer:
3. If you already have Enum type created in your code, then you can use that as a data type of any entity property.