DbContext::GetValidationErrors Method

Entity Framework 5.0

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

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

public:
IEnumerable<DbEntityValidationResult^>^ GetValidationErrors()

Return Value

Type: System.Collections.Generic::IEnumerable<DbEntityValidationResult>
Collection of validation results for invalid entities. The collection is never nullptr and must not contain nullptr values or results for valid entities.

This method calls DetectChanges() to determine states of the tracked entities unless AutoDetectChangesEnabledis set to false. By default only Added and Modified entities are validated. You can change this behavior by overriding the ShouldValidateEntity(DbEntityEntry) method.

Show: