etrupja / complete-ecommerce-aspnet-mvc-application

This is the source code of the "ASP.NET MVC | Build a Complete eCommerce App" course on Udemy
https://bit.ly/3CWvkqk
255 stars 295 forks source link

While Adding New Actor #10

Open omkar-shah opened 11 months ago

omkar-shah commented 11 months ago

As the actor model has Actor_Movies relation when we create new actor (ModelState.IsValid) this function not let us add data to create new actor what is the solution for it can you Help me out??

salithedeveloper commented 8 months ago

I had this error as well when using .NET 8.0 framework. I resolved this by adding the [ValidateNever] tag on the Actors_Movies property of the Actor.cs file. Here is the code snippet:

//Relationships
[ValidateNever]
public List<Actor_Movie> Actors_Movies { get; set; }

I believe the issues stem from changes in how model validation works in later versions like .NET 8 (the course uses 5.0) has evolved over time, and there have been updates and changes in model binding and validation behaviors.

salithedeveloper commented 1 month ago

it works how did you know that even chat gpt cant resolve it

I just did a lot of trial and error. Since taking the course, I have hit many issues, but each time with enough debugging and with the help of ChatGPT as well, I'm usually able to find a solution. The more issues you find, the more you will learn. Good luck!