Join our book community on Discord
https://packt.link/EarlyAccess/
This chapter is about model binding, model validation, and retrieving and modifying data using EF Core in an ASP.NET Core MVC website project. These concepts work together to simplify the common tasks of taking user input, processing it, and storing or retrieving data from a database.
Model binding is at the heart of how ASP.NET Core MVC applications interact with user input. When a user submits a form, the data in that form needs to be mapped to the models (objects or classes) in your application. Model binding automates this process, converting incoming HTTP request data like form fields, query strings, and route data into C# objects that your application can work with.
Model validation ensures that the data coming into your application meets the defined rules before it is processed or saved. In ASP.NET Core MVC, this is often achieved by decorating your models with data annotations like [Required]
, [StringLength...