Summary
We learned about custom validations that were provided by Entity Framework and MVC in this chapter. We started with client-side validation, which changed the user experience completely, then looked at what would happen if somebody hacks in and bypasses the client-side validation. We overcame those issues by applying second-level validation at the server side. We saw the urge in performing manual validation rather than the framework doing it for us out of the box; we then performed some custom validation that was required beyond the built-in validations. We also applied the same validation to the client side by leveraging IClientModelValidator
. Finally, we performed a remote validation that was not even a part of Entity Framework but was available in the MVC Framework.
So far, we were accessing the data only through data context, and we have never written any plain SQL queries. In a few valid scenarios, we had a need for the provision to bypass the data context for better performance...