Clarify the basics of proxies
No mention of these.. now I need to go figure
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 24b2b50e-35f8-9e0b-8ce5-840e1ea816e6
- Version Independent ID: 9e0e6e2c-48fa-76c3-3bd9-813a6df22645
- Content: Relationships - EF Core
- Content Source: entity-framework/core/modeling/relationships.md
- Product: entity-framework
- GitHub Login: @rowanmiller
- Microsoft Alias: divega
@pav1 can you please be more specific?
I think they are saying "virtual" isn't mentioned anywhere and that's pretty common in EF so it should likely be explained how it's being used in regards to Entity Framework. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/virtual doesn't really make sense in the context of Entity Framework.
I believe "virtual" in the model class is used for lazy loading @KSib
@ZeroPKI Right, but where is that in the documentation that OP posted? That's the problem. I think there's a lot of confusion here for some reason.
EF "Overrides" classes with a "proxy" class, which is nothing else but a subclass that inherits from your data class. To be able to intercept/modify requests, by example, when using lazy loading, it needs to override properties in an OOP way, and doing so adds code to the get; set; of the properties to check values, do lazy loading and assign primary keys returned by the database. If you don't use virtual, EF has no way do its magic as cannot intercept the requests.
See also discussion in https://github.com/dotnet/efcore/issues/19035