Is it possible to check the entities that I have already added to the context before I call SaveChanges and remove the invalid ones so that I do not get EntityValidationErrors when saving?
I have a list of about 3 thousand entities, and some of them contain invalid data that prevents all other objects from being saved. I would not want to keep each unit separately, but ignore those that have errors.
Trying to find a solution, I found that you can turn off validation. If I did, would SaveChanges ignore the invalid and save the rest?
Context.Configuration.ValidateOnSaveEnabled = false;
I would prefer to call some method to invoke the authentication of the object and remove it from the context. Or perhaps it is even possible to validate an object before I add it to the context? It will be even better.
source share