HOTSPOT
You are maintaining a ASP.NET Core web application that uses Entity Framework Core for data access. The application contains a model class named Student.
You must add a field named FirstName to the class. The field has following requirements:
Use a non-nullable field named FName to store data in a Microsoft SQL Server database. The data length must be between 2 and 50 characters.
The application user interface must display an error message if the maximum or minimum length requirements are not met.
You need to implement the FirstName field.
How should you complete the code? To answer, select the appropriate code segments to use in the answer area.
NOTE: Each correct selection is worth one point.
Hot Area:
1. Required
2. StringLength
3. Column
Correct
Agree with Johnny. The answers should be 1) Required (there’s no requirement to display an error message on this), Range with the error message, Column(“FName”)
That Compare makes no sense. It should be:
Required
StringLength
Column
You use DisplayColumn on foreign key columns, which is not the case here. Display is used for localizable strings.