DbContext.GetValidationErrors Method


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

[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)


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



  1. This method calls DetectChanges() to determine states of the tracked entities unless

DbContextConfiguration.AutoDetectChangesEnabled is set to false.

  1. By default only Added on Modified entities are validated. The user is able to change this behavior

by overriding ShouldValidateEntity method.

Applies to