Search code examples
.netentity-frameworkasp.net-mvc-4wcf-data-servicesef-database-first

Entity Framework with Database First model


I am developing in ASP.NET MVC with EF 4.1 with Data Annotations. The client side validation is working as expected. But I have this doubt. For example when a required field (example: product name) , goes null from the client to server and if the entity model is throwing exception. How can I handle this case?

Some additional info is that, I consume the EF via WCF service layer


Solution

  • You should be validating the model on the server side/controller too by calling model.isvalid, for more info on MVC server side validation:

    http://msdn.microsoft.com/en-us/library/dd410404(v=vs.90).aspx

    Hope that helps.