Catch Database Exceptions - DbEntityValidationException - Entity Framework
Catch Database Exceptions - DbEntityValidationException - Entity Framework (C#,.NET) When you developing .net application with C#, EntityFramework you may get " Validation failed for one or more entities " error sometimes. With this error you can't find exact error or entity field directly. you may have to do some extra work for that. I am using following simple code for simply find error field. This is straightforward and very very small code. We can catch our database exseptions Using DbEntityValidationException (Under namespace System.Data.Entity.Validation) in EntityFramework. Im using EntityFramework.6.x. It is also available in EntityFramework 5.x. In here i am writing my exceptions in to text file in my C: drive ( C:\Shared\Error.txt ) Remember you have to give proper permissions for C: drive if you want to write data into text file. I am here i am using this for simplicity and tutorial purpose. try { //Your database operations....