Skip to content
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

Owned entities + lazy loading #2382

Closed
justSimpleDeveloper opened this issue May 13, 2020 — with docs.microsoft.com · 1 comment
Closed

Owned entities + lazy loading #2382

justSimpleDeveloper opened this issue May 13, 2020 — with docs.microsoft.com · 1 comment

Comments

Copy link

justSimpleDeveloper commented May 13, 2020

Why after using loading for context i'm forced to use it for each and every entity/navigation property?
By turning on lazy loading for context, all my navigation properties needs to be lazy ones. When I combine it with entity having owned type it causes having additional join in SQL read (from the same table to the same one). Finally having one row with 4 owned types (4 of the same type, each having two columns), instead of having single "select columns from table",
I have such overheaded SQL:

SELECT TOP(2) [m].[Id], [t].[Id], [t].[DayPeriodConfiguration_ErrorIndicator], [t].[DayPeriodConfiguration_WarningIndicator], [t0].[Id], [t0].[HourPeriodConfiguration_ErrorIndicator], [t0].[HourPeriodConfiguration_WarningIndicator], [t1].[Id], [t1].[MonthPeriodConfiguration_ErrorIndicator], [t1].[MonthPeriodConfiguration_WarningIndicator], [t2].[Id], [t2].[WeekPeriodConfiguration_ErrorIndicator], [t2].[WeekPeriodConfiguration_WarningIndicator]
FROM [Integration].[MessagesStatusReportConfiguration] AS [m]
LEFT JOIN (
    SELECT [m0].[Id], [m0].[DayPeriodConfiguration_ErrorIndicator], [m0].[DayPeriodConfiguration_WarningIndicator]
    FROM [Integration].[MessagesStatusReportConfiguration] AS [m0]
    WHERE [m0].[DayPeriodConfiguration_WarningIndicator] IS NOT NULL AND [m0].[DayPeriodConfiguration_ErrorIndicator] IS NOT NULL
) AS [t] ON [m].[Id] = [t].[Id]
LEFT JOIN (
    SELECT [m1].[Id], [m1].[HourPeriodConfiguration_ErrorIndicator], [m1].[HourPeriodConfiguration_WarningIndicator]
    FROM [Integration].[MessagesStatusReportConfiguration] AS [m1]
    WHERE [m1].[HourPeriodConfiguration_WarningIndicator] IS NOT NULL AND [m1].[HourPeriodConfiguration_ErrorIndicator] IS NOT NULL
) AS [t0] ON [m].[Id] = [t0].[Id]
LEFT JOIN (
    SELECT [m2].[Id], [m2].[MonthPeriodConfiguration_ErrorIndicator], [m2].[MonthPeriodConfiguration_WarningIndicator]
    FROM [Integration].[MessagesStatusReportConfiguration] AS [m2]
    WHERE [m2].[MonthPeriodConfiguration_WarningIndicator] IS NOT NULL AND [m2].[MonthPeriodConfiguration_ErrorIndicator] IS NOT NULL
) AS [t1] ON [m].[Id] = [t1].[Id]
LEFT JOIN (
    SELECT [m3].[Id], [m3].[WeekPeriodConfiguration_ErrorIndicator], [m3].[WeekPeriodConfiguration_WarningIndicator]
    FROM [Integration].[MessagesStatusReportConfiguration] AS [m3]
    WHERE [m3].[WeekPeriodConfiguration_WarningIndicator] IS NOT NULL AND [m3].[WeekPeriodConfiguration_ErrorIndicator] IS NOT NULL
) AS [t2] ON [m].[Id] = [t2].[Id]

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@ajcvickers
Copy link
Member

See dotnet/efcore#10787 and dotnet/efcore#12462 In particular, dotnet/efcore#12462 is fixed in the EF Core 5 previews which are available now on NuGet and should stop owned properties from being lazy-loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants