You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then I want to fetch all data from WorkerShare and order them by the primary keys which, at the same, are foreign keys. And here's the thing - I get completely different T-SQL when I use:
• Navigation properties (ActConfig and WorkTypeCode)
• Foreign keys [primary keys] (ActConfigId and WorkTypeCodeId)
As you see, using navigation properties generates inefficient T-SQL with unnecessary joins. The query orders the result by primary keys in referenced tables (ActConfig and WorkTypeCode), but at the same time these keys exist in referencing table (WorkerShare). There's no sense in using joins.
Further technical details
EF Core version: 3.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows 10 Home x64, OS build 18363.535
IDE: Visual Studio 2019 16.5.0 Preview 1.0
The text was updated successfully, but these errors were encountered:
I have three tables which are connected the following way:
ActConfig entity:
WorkTypeCode entity:
WorkerShare entity:
Then I want to fetch all data from WorkerShare and order them by the primary keys which, at the same, are foreign keys. And here's the thing - I get completely different T-SQL when I use:
• Navigation properties (
ActConfig
andWorkTypeCode
)• Foreign keys [primary keys] (
ActConfigId
andWorkTypeCodeId
)C# queries:
The corresponding T-SQL and execution plans:
As you see, using navigation properties generates inefficient T-SQL with unnecessary joins. The query orders the result by primary keys in referenced tables (
ActConfig
andWorkTypeCode
), but at the same time these keys exist in referencing table (WorkerShare
). There's no sense in using joins.Further technical details
EF Core version: 3.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows 10 Home x64, OS build 18363.535
IDE: Visual Studio 2019 16.5.0 Preview 1.0
The text was updated successfully, but these errors were encountered: