I am trying to update an entity in Entity Framework but I get this error
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
Code:
public message getDetailedMessage(int message_id)
{
message msg = new message();
if(context.messages.Any(mesg => (mesg.C_From == CurrentUser.Id && mesg.id == message_id) || (mesg.Receivers.Any(receiver => receiver.ReceiverId == CurrentUser.Id && receiver.MessageId == message_id))))
{
msg = context.messages.Where(mesg => mesg.id == message_id).FirstOrDefault();
msg.Status = "R";
context.SaveChanges();
}
else
{
msg.MDTO.HasError = true;
msg.MDTO.Error = "You do not have the permission to read this inbox";
}
return msg;
}
This is the schema of the table
Could anybody please help me to resolve this error?