Closed devbased closed 10 months ago
I thought it is a rare case, but in the project I work on, it turned out that many entities have the same name but are located in different namespaces. There are also some collisions with System (for example, we have a domain entity called TimeZone) 😔
Duplicate of #27203
Description
The issue arises when using Compiled Models. Types are not identified by their 'FullName'. Thus, if user code has a custom type with the same name as a generated type, a runtime
NullReferenceException
will occur when attempting to access a navigation property with lazy-loading enabled.Steps To Reproduce
A
andB
with a navigation property between themAEntityType
enum in a separate namespacepublic AEntityType EntityType { get; set; }
toB
DbContext
configurationA
entityB
navigation propertyNullReferenceException
will occur when accessingB
Code Sample
Stack Trace
General Info
EF Core version: 7.0.11 Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 7.0 Operating system: Windows 10 IDE: JetBrains Rider 2023.2