Entity Framework Core Interview Question #151

What is a value converter in EF Core?

Advanced Mapping, Interceptors, Value Conversions & Architecture Senior Advanced

Quick Interview Answer

A value converter transforms a property value between the CLR representation used by the application and the provider value stored in the database. Common uses include storing enums as strings, wrapping primitive values in domain types, or converting application-specific formats. Converters affect persistence representation; they do not replace validation or encryption design.

Detailed Explanation

A value converter transforms a property value between the CLR representation used by the application and the provider value stored in the database. Common uses include storing enums as strings, wrapping primitive values in domain types, or converting application-specific formats. Converters affect persistence representation; they do not replace validation or encryption design.

Code Example

modelBuilder.Entity<Order>()
    .Property(o => o.Status)
    .HasConversion<string>();