Skip to content

Revised ValidationContext.MemberName #2366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions xml/System.ComponentModel.DataAnnotations/ValidationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,20 @@
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
This property represents an entity member name, not the name of a corresponding data field. Therefore, this name is not a localized name. It should be set only for property or parameter contexts.

## Remarks

This property represents an entity member name, not the name of a corresponding data field. Therefore, this name is not a localized name. It should be set only for property or parameter contexts.

In .NET Framework 4.7.2 and earlier versions, when using a custom <xref:System.ComponentModel.DataAnnotations.ValidationAttribute?displayProperty=nameWithType>, the `MemberName` property returns `null`. Starting with .NET Framework 4.8, you can change the default behavio so that the property returns the member name by adding the following setting to your app config file:

```xml
<configuration>
<appSettings>
<add key="aspnet:GetValidationMemberName" value="true" />
</appSettings>
</configuration>
```

]]></format>
</remarks>
</Docs>
Expand Down