[ASP.NET Core MVC - Movie Database tutorial] SqlNullValueException: Data is Null' error occurs after adding the [Required] attribute to the 'Rating' field in a Movie class while working on 'Part 9: Adding Validation to an ASP.NET Core MVC App.'
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
**Issue Summary:** I encountered a 'SqlNullValueException: Data is Null' error while working on 'Part 9: Adding Validation to an ASP.NET Core MVC App.' This error occurred when I added the [Required] attribute to the 'Rating' field in my Movie class.
**Description:** Before adding the validation rules [before Part 9], my code worked just fine. However, after implementing the required attributes, the code broke. To diagnose the issue, I began debugging it line-by-line and discovered that the 'SqlNullValueException: Data is Null' error occurred immediately after adding the `[Required]` attribute to the 'Rating' field.
**Solution:** I removed the attribute from my code, and this action resolved the issue. I believe this workaround could be helpful to anyone who encounters a similar problem and finds themselves stuck while moving forward.
### Expected Behavior
_No response_
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
8.0.101
### Anything else?
Microsoft Visual Studio Community 2022 (64-bit) : Version 17.8.1
Microsoft .NET Version ; 4.8.09032
Contributor guide
Assessment
This issue has not been assessed yet.