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

前端 未结 16 1421
盖世英雄少女心
盖世英雄少女心 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:00

    I also faced the same problem with you and now I already resolved this. With HttpGet you need to return a View will empty model. Such as

    [HttpGet]
    public ActionResult Add()
    {
        //Your code here
        return View(new Venue);
    }
    

    I hope it is useful with you.

提交回复
热议问题