我有一个这样的模型
public int Id {get;set;}
[Required]
public string FirstName{get; set}
[Required]
public string LastName{get; set}
Id 是在 DB 中自动生成的。当我想调用创建操作时,ModelState 说“需要 Id 字段”!!!!我为我的问题找到了这个,但它不是干净的解决方案。有没有其他方法可以解决这个问题?
有没有办法更改值类型的 Mvc ModelBinder 行为?