The “X” property on “Y” could not be set to a 'null' value. You must set this property to a non-null value of type 'Int32'

前端 未结 11 1391
花落未央
花落未央 2020-12-29 21:38

When I run my application and I click a specific button I get the error:

\"The \"X\" property on \"Y\" could not be set to a \'null\' value. You must set thi         


        
11条回答
  •  旧时难觅i
    2020-12-29 21:58

    Check your model & database both should be defined accordingly....

    public Int32? X { get; set; } ----> Nullable Accordingly in DB 'X' should be Nullable = True

    or

    public Int32 X { get; set; } ----> not Nullable Accordingly in DB 'X' should be Nullable = false

提交回复
热议问题