You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obsoleting AddDataAnnotationsValidation and replacing with EnableDataAnnotationsValidation
The extension method EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation is being marked as obsolete. Developers should use the new extension method EditContextDataAnnotationsExtensions.EnableDataAnnotationsValidation instead.
The only difference between these two APIs is in their return values:
The older API returns its EditContext (as a kind of fluent API).
New behavior
The new API returns an IDisposable whose disposal can be used to remove the data annotations validation support from the EditContext.
Reason for change
There are cases where it's desirable to remove the data annotations validation support after adding it. This was not possible with the older API because there was no place to store the internal event subscriptions. The new API returns an object that holds the state necessary to remove data annotations validation support on disposal.
Recommended action
This does not affect most applications, because most applications do not call this directly anyway. Most applications instead use the <DataAnnotationsValidator> component, and do not need to be changed. The use of the extension methods discussed here is a rare and advanced case.
However, if you do call editContext.AddDataAnnotationsValidation(), then replace that call with editContext.EnableDataAnnotationsValidation(). Optionally, captured the new returned IDisposable and dispose it if you later wish to undo the effects of the call.
Obsoleting AddDataAnnotationsValidation and replacing with EnableDataAnnotationsValidation
The extension method
EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation
is being marked as obsolete. Developers should use the new extension methodEditContextDataAnnotationsExtensions.EnableDataAnnotationsValidation
instead.The only difference between these two APIs is in their return values:
Version introduced
6.0
Old behavior
The older API returns its
EditContext
(as a kind of fluent API).New behavior
The new API returns an
IDisposable
whose disposal can be used to remove the data annotations validation support from theEditContext
.Reason for change
There are cases where it's desirable to remove the data annotations validation support after adding it. This was not possible with the older API because there was no place to store the internal event subscriptions. The new API returns an object that holds the state necessary to remove data annotations validation support on disposal.
Recommended action
This does not affect most applications, because most applications do not call this directly anyway. Most applications instead use the
<DataAnnotationsValidator>
component, and do not need to be changed. The use of the extension methods discussed here is a rare and advanced case.However, if you do call
editContext.AddDataAnnotationsValidation()
, then replace that call witheditContext.EnableDataAnnotationsValidation()
. Optionally, captured the new returnedIDisposable
and dispose it if you later wish to undo the effects of the call.Category
ASP.NET
Affected APIs
EditContextDataAnnotationsExtensions.AddDataAnnotationsValidation(EditContext)
Issue metadata
The text was updated successfully, but these errors were encountered: