-
-
Notifications
You must be signed in to change notification settings - Fork 161
Description
SUMMARY
A resource model might have explicitly mapped foreign keys, like the Post entity at https://learn.microsoft.com/en-us/ef/core/modeling/relationships#mapping-relationships-in-ef-core. Typically both the foreign key and and navigation property are expected to be not null if the relationship is required.
When ResourceObjectAdapter converts from document to entity it sets navigation property from relationship but not foreign key property. It will be peristed ok but is unexpectedly null until retrieved from database again. This can cause confusement when for example extending EntityFrameworkCoreRepository and iteract with the entity before persisting. I have encountered this when creating entities with relations using atomic operations, not sure it is relevant elsewhere.
Would it make sense to resolve foreign key mapping and set it in this case?
VERSIONS USED
- JsonApiDotNetCore version: 5.9.1
- ASP.NET Core version: 8.0.21
- Entity Framework Core version: 9.0.10
- Database provider: Npgsql.EntityFrameworkCore.PostgreSQL 9.0.4