Is it possible to validate entities that I've already added to the context before I call SaveChanges
and remove the invalid ones so that I don't get the EntityValidationErrors
on save?
I have a list of about 3k entities and some of them contain invalid data that prevent all other entities to be saved. I wouldn't like to save each entity separately but rather ignore those that have errors.
Trying to find a solution to this I found that you can disable the validation. If I did it, would SaveChanges
ignore the invalid ones and save the others?
Context.Configuration.ValidateOnSaveEnabled = false;
I would however prefer to call some method to invoke entity validation and remove it from the context. Or maybe it's even possible to validate an entity before I add it to the context? This would be even better.