Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To rectify the issue of mandatory fields in an EF core-built .NET core API, follow the steps below:

  1. Open the model class in which the mandatory field is defined.
  2. Add the "[Required]" attribute to the corresponding property. This attribute indicates that the field is mandatory.
  3. Save the changes and rebuild the project.
  4. Test the API using Swagger or any other client application to confirm that the mandatory field is properly validated.

If the issue persists, check if the "ApiController" attribute is present at the top of the controller and whether the "services.AddControllers();" line is included in the startup.cs file. If not, add them, rebuild the project, and test again.