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.

 

posted @ 2017-03-26 12:54  蓝平凡  阅读(291)  评论(0编辑  收藏  举报