I have created a nullable corporateSponsorName. However, I am not able to have an empty value to my database.. when I tried console.log, it shows me "" which the actual code did not mention "data-val="true" data-val-required="The Corporate Sponsor Name* field is required.""
may i know how to turn off that data-val-required?
As this document said:
Beginning with .NET 6, new projects include the
<Nullable>enable</Nullable>element in the project file. Once the feature is turned on, existing reference variable declarations become non-nullable reference types.
In .NET 6 the non-nullable property must be required.
To achieve your requirement, you can remove <Nullable>enable</Nullable> from your project file (Right-click on the project name in the Solution Explorer, and then select Edit Project File from the menu).
Another way is that you can add ? to allow nullable, e.g:
public class Test
{
public string? Name { get; set; }
public string? Id { get; set; }
//other proerpties..
}
If you do not use .NET 6, it will not make property required by default unless you add [Required] attribute on the property.