Does EF7 (EFCore) support enums?

前端 未结 2 874
不知归路
不知归路 2021-01-18 08:00

I have problem with EF7 RC1 (EFCore). I am unable to work with enums in my model. I can save enum property. The value is casted to int. My problem is that during data readin

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-18 08:30

    This worked for me. I am using "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final" in project.json. I had to run ef migrations database update as part of pushing the model.

    public class Person
    {
        public int PersonId { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public int PersonTypeId { get; set; }
        public PersonType PersonType { get; set; }
        public ActiveType ActiveType { get; set; }
    }
    
    public enum ActiveType
    {
        Active = 0,
        Inactive = 1
    }
    

提交回复
热议问题