So I am trying to do get the key for a model object in the controller so that I can add a AddModelError to it.
In my view I use
@Html.ValidationMessageFor(model => model.Email)
Whats the equivalent code to get the Key name to add in the controller so it attaches to this ValidationMessage.
But usually that’s not something you should be doing manually in your controller but you should be using a validator. For example you could decorate this Email property with some validation data annotation attribute or if you are like me use FluentValidation.NET => this way you shouldn’t be asking yourself questions about keys but focus on the actual validation logic.