When saving data with Entity Framework, you may encounter a validation failed exception, which does not provide specific information about the source of the problem. To access the errors, you need to add a try catch block in the code and handle the DB entity validation exception.
In this specific case, the exception was thrown when adding a new movie to the database. By inspecting the exception object, it was discovered that the genre field is required. Two possible solutions were presented: either moving the required attribute from the genre property to the genre ID property in the movie class, or reading the genre with a given ID from the database before saving the changes in the controller.
In the end, the first approach was chosen, and the required attribute was applied to the genre property. With this modification, the exception is resolved and the issue is solved.
video txt