Model
Set Primary key inside: [key] can customize the primary key by default is a field named ID type int
Set display format: [DisplayFormat (dataformatstring= "{0: Format shown}", [optional parameter])
Set field display content [Display (Name = "What to display")] Example:
[Display (Name = "Release date")] Public DateTime releasedate {get; set;}
The foreground will show the publication date on the title bar of the field by default
[required]//is not allowed to be empty [stringlength (60,minimumlength = 5)]//Set the length to 5-60[range (1,100)]//set the input range and limit the input data to a number [DataType ( datatype.currency)]//limit the input data to the currency type of the parameter here DataType inside is an enumeration value of course can also define their own
[RegularExpression(@"^[A-Z]+[a-zA-Z‘‘-‘\s]*$")]//这里放的是正则表达式
The *.cshtml page in view cancels the validation
asp-validation-summary= "TypeName" just give this attribute to cancel it.
In the controller
[validateantiforgerytoken]//Declaration validation validity with if (modelstate.isvalid) {//something} Validation of validity
ASP. NET Core Primer-based content backup