How do I solve SqlNullValueException?

前端 未结 1 1648
长发绾君心
长发绾君心 2021-01-18 20:20

I\'m trying to find an entity but I get a SqlNullValueException when entity framework is trying to get the value of a field that\'s Null.

I checked in the database a

相关标签:
1条回答
  • 2021-01-18 20:46

    you have to mark all nullable CodeLists properties with Nullable data types like below:

    public class CodeLists
    {
        public Guid Id { get; set; }
        public Guid? ClassificationId { get; set; }
        public Guid? DescriptionId { get; set; }
    
        public Guid NameId { get; set; }
        public Guid? OwnerId { get; set; }
    
    }
    
    

    ClassificationId and OwnerId are not nullable in your CodeLists class implmementation but is nullable in the Db

    0 讨论(0)
提交回复
热议问题