Share via


DbContext.GetValidationErrors Method

Definition

Validates tracked entities and returns a Collection of DbEntityValidationResult containing validation results.

public System.Collections.Generic.IEnumerable<System.Data.Entity.Validation.DbEntityValidationResult> GetValidationErrors ();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public System.Collections.Generic.IEnumerable<System.Data.Entity.Validation.DbEntityValidationResult> GetValidationErrors ();
member this.GetValidationErrors : unit -> seq<System.Data.Entity.Validation.DbEntityValidationResult>
Public Function GetValidationErrors () As IEnumerable(Of DbEntityValidationResult)

Returns

Collection of validation results for invalid entities. The collection is never null and must not contain null values or results for valid entities.

Attributes

Remarks

1. This method calls DetectChanges() to determine states of the tracked entities unless DbContextConfiguration.AutoDetectChangesEnabled is set to false. 2. By default only Added on Modified entities are validated. The user is able to change this behavior by overriding ShouldValidateEntity method.

Applies to