EFC8: Lazy Loading regression on newly created objects #32314
Labels
area-change-tracking
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
Servicing-approved
type-bug
Milestone
When creating a new object that uses
ILazyLoader
, theLazyLoader
will be populated when the object is added to a DbSet.If you now access a navigation property on the newly created object (e.g. check it for null during initialization and set it otherwise) before having called SaveChanges, EFC8 will now throw the following error:
In EFC7 there was no such error being generated.
I currently see two possible workarounds: Catch and discard the exception or delay associating the newly created object with the DbContext for as long as possible.
Include provider and version information
EF Core version: 8.0
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 8.0
Operating system: Windows 10
IDE: Visual Studio 2022 17.8
The text was updated successfully, but these errors were encountered: