Skip to content

Fixes for EF Core owned entities #1272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2023
Merged

Fixes for EF Core owned entities #1272

merged 1 commit into from
May 12, 2023

Conversation

bkoelman
Copy link
Member

@bkoelman bkoelman commented May 10, 2023

This PR fixes two problems when using owned entities:

  1. Owned entity properties are not retrieved when using sparse fieldsets (because they are modeled as navigations in EF Core, instead of scalar properties).
  2. When producing a LINQ query that includes an owned entity, EF Core produces an error, indicating that the query must be marked as non-tracked. Due to potential performance impact, a virtual method is provided that enables tweaking the behavior.

Closes #1271.

QUALITY CHECKLIST

@bkoelman bkoelman force-pushed the fix-owned-entities branch from c301d7a to 211d489 Compare May 10, 2023 23:44
@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Merging #1272 (ff4802c) into master (627bae9) will decrease coverage by 0.17%.
The diff coverage is 88.23%.

❗ Current head ff4802c differs from pull request most recent head 779daea. Consider uploading reports for the commit 779daea to get more accurate results

@@            Coverage Diff             @@
##           master    #1272      +/-   ##
==========================================
- Coverage   92.98%   92.82%   -0.17%     
==========================================
  Files         255      255              
  Lines        8242     8233       -9     
==========================================
- Hits         7664     7642      -22     
- Misses        578      591      +13     
Impacted Files Coverage Δ
...Core/Repositories/EntityFrameworkCoreRepository.cs 96.03% <77.77%> (-0.59%) ⬇️
.../Internal/QueryableBuilding/SelectClauseBuilder.cs 99.14% <100.00%> (+0.01%) ⬆️
...DotNetCore/Resources/ResourceDefinitionAccessor.cs 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

@bkoelman bkoelman force-pushed the fix-owned-entities branch from 211d489 to 786306c Compare May 11, 2023 00:41
@bkoelman bkoelman changed the base branch from master to update-examples May 11, 2023 00:42
@bkoelman bkoelman requested a review from maurei May 11, 2023 00:47
Base automatically changed from update-examples to master May 11, 2023 05:24
@bkoelman bkoelman marked this pull request as ready for review May 12, 2023 07:59
1. Owned entity properties are not retrieved when using sparse fieldsets (because they are modeled as navigations in EF Core, instead of scalar properties)
2. When producing a LINQ query that includes an owned entity, EF Core produces an error, indicating that the query must be marked as non-tracked. Due to potential performance impact, a virtual method is provided that enables tweaking the behavior.
@bkoelman bkoelman force-pushed the fix-owned-entities branch from 786306c to 779daea Compare May 12, 2023 07:59
@maurei maurei merged commit 2596635 into master May 12, 2023
@maurei maurei deleted the fix-owned-entities branch May 12, 2023 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent and Erroring Behavior When Using EF OwnsOne/OwnsMany Mapping
2 participants