Advertisement
Advanced C#, Records & Pattern Matching

When should you NOT use records?

Short answer

For entities with identity and mutable state (like EF Core aggregates), where value equality and immutability are wrong; use classes there. Records suit values, not entities.

Save C# mock interview
Advertisement
AModel answer
For entities with identity and mutable state (like EF Core aggregates), where value equality and immutability are wrong; use classes there. Records suit values, not entities.
public class Order { public int Id { get; set; } public string Status { get; set; } }
Real-world example
An EF Core entity tracked by Id stays a class; a money value object becomes a record.