Not null parameter in Int fields

0

I'm creating an application in Asp.NET MVC (I'm using the Scafffolded feature), however, all the fields are being filled in, how do I remove this parameter?

Note: I've tried unchecking the "Allow null value" option in the database, but without success.

I'm finding that this validation is occurring in .cshtml , but I have not located it.

Template.

public class prospectModel 
{ 
    public int id { get; set; } 
    public string contato { get; set; } 
    public string nomeRazaoSocial { get; set; } 
    public int documento { get; set; } 
    public int telefone { get; set; } 
    public int celular { get; set; } 
    public string email { get; set; } 
    public string anotacoes { get; set; } 
}

cshtml

<div class="form-group"> @Html.LabelFor(model => model.celular, htmlAttributes: new { @class = "control-label col-md-2" }) 
    <div class="col-md-10"> @Html.EditorFor(model => model.celular, new { htmlAttributes = new { @class = "form-control" } })@Html.ValidationMessageFor(model => model.celular, "", new { @ class = "text-danger" })
    </div> 
</div>
    
asked by anonymous 07.03.2018 / 13:29

1 answer

0

Since integer is a primitive type it does not allow null values, in your case it must accept, ie you should mark this property as nullable in your view model:

public int? Idade {get; set; }
    
07.03.2018 / 13:56