“The Id field is required” validation message on Create; Id not set to [Required]

前端 未结 16 1314
盖世英雄少女心
盖世英雄少女心 2020-12-07 17:18

This is happening when I try to create the entity using a Create style action in Asp.Net MVC 2.

The POCO has the following properties:

public int Id          


        
16条回答
  •  时光说笑
    2020-12-07 18:03

    Above answers are correct. Any how every one follow different scenario .My solution is as follows for the same problem. If your ID is a primary key then you need to initiate it I mean to say when you are passing model to view in get method just create new object before it . It will set 0 to your ID instead of null.

提交回复
热议问题