Open cremor opened 11 months ago
For one thing, many people come to records in search of a quick-and-easy immutable type (and indeed, minimal record syntax with a primary constructor does produce an immutable type). Immutable types don't work well with EF regardless of records (https://github.com/dotnet/efcore/issues/11457).
For another, records are very much about defining the equailty behavior of the type to be value equality. EF can indeed ignore that and use reference equality, but that's once again not what many users expect - after all, they've chosen to user records for a reason ("I've chosen value semantics, why does EF override that?").
All that isn't to say that it's impossible to use records with EF, just that it's usually not what users want. I agree the documentation on this can be improved though.
The page https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/records mentions this:
There is no mention of this on the page Entity Types - EF Core or any other page in the EF Core documentation that I could find.
Please expand the EF core documentation to clearify the use of record types.
Please also include an explanation for why the default value equality of record types is actually a problem for EF Core. (If EF Core depends on reference equality (like documented above), then why doesn't EF Core just always use reference equality and ignore the equality implementation of the entity type?
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.