dotnet / dotnet/EntityFramework.Docs
Document the use of record types as entities
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
The page https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/records mentions this:
> # When to use records
> ## Value equality
> Not all data models work well with value equality. For example, [Entity Framework Core](https://learn.microsoft.com/en-us/ef/core/) depends on reference equality to ensure that it uses only one instance of an entity type for what is conceptually one entity. For this reason, record types aren't appropriate for use as entity types in Entity Framework Core.
There is no mention of this on the page [Entity Types - EF Core](https://learn.microsoft.com/en-us/ef/core/modeling/entity-types) 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.*
* ID: 6ffdc279-736f-92e4-6de3-cce42342cd6b
* Version Independent ID: d3d4904a-f60d-a0a2-b634-cb12671fa7a2
* Content: [Entity Types - EF Core](https://learn.microsoft.com/en-us/ef/core/modeling/entity-types?tabs=data-annotations)
* Content Source: [entity-framework/core/modeling/entity-types.md](https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/modeling/entity-types.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @AndriySvyryd
* Microsoft Alias: **avickers**
Contributor guide
Assessment
This issue has not been assessed yet.