Can we avoid using Include when referencing an EF Core assembly
When we reference an EF Core assembly, we get the advantage of being able to use properties on the models, navigation properties being correctly named, etc.
However, one thing we lose is that with Linq2Sql, you don't need to include navigation properties, you can just do...
Customers.Single(c => c.Id == 3).Orders
...and it loads. When referencing an EF Core assembly, we have to do...
Customers.Include(c => c.Orders).Single(c => c.Id == 3).Orders
Is there a way of avoiding this? Thanks
Comments
Have you tried enabling lazy loading in EF Core?
https://docs.microsoft.com/en-us/ef/core/querying/related-data/lazy
Didn't try it, because we don't want it enabled in the real project, for the performance reasons explained in the article linked from yours.
Is that the only way to avoid this issue? Thanks
You're describing the exact problem that lazy loading fixes
You can easily configure your context to enable lazy loading only when used from LINQPad. Click the "Help me choose" hyperlink on the dialog for an example.
Thanks for the heads-up on that link, never thought to check it, as I already had the right constructor!
All works fine now.