I am having a similar problem in two ASP.NET applications with Entity Framework.
When I try to update an entity that already has all the required mandatory attributes I get a EntityValidationErrors
exception, however this property that is described in validarion
is populated.
The weird thing is that if I put the breakpoint and check the attributes of the object they are all filled and does not cause the error.
In one of the applications I'm getting around this problem by getting the property to receive itself or simply accessing the property and throwing its value into any variable:
ComentariosBlog model = _comentariosBlogNegocios.GetById(idComentatio.Value);
if (model == null)
return HttpNotFound();
model.Ativo = status.Value;
var teste = model.Publicacao; //<----Contorno
idPost = model.PublicacaoId;
_comentariosBlogNegocios.Salvar(model);
I already have a Try Catch block that handles this error, the problem is that the object has all the required properties filled in and I have to do a "gambi" so that it does not generate errors like this in the above code! The simple fact of accessing the property and playing it in any variable is already in order to give error, but I need a more correct solution to this problem, as I said this is just a "gambi"!
Here are the details of the error that is generated:
Inthisimagewecanseethatthementionedpropertyisalreadyfilled:
Here is the error message inside the try catch: