About loading navigation properties
Why does linqpad7 not automatically load the navigation properties of the table? How to fix it?
Comments
-
Are you connecting to a typed DbContext in your own assembly? If so, you must enable lazy-loading in your typed DbContext class as follows:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseLazyLoadingProxies(); base.OnConfiguring(optionsBuilder); }
You will also need to add a NuGet package reference to Microsoft.EntityFrameworkCore.Proxies:
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0" />
If you want to enable lazy loading only when querying from LINQPad, see https://linqpad.azureedge.net/public/SampleDbContext.cs
-
Lazy loading has been enabled in dbcontext.But it does not work .
-
When I enable optionsbuilder Isconfigured is not available. Comments are available. What's the impact?Tanks!!!
-
Hello ,
I have the same problem.
Dis it work for you ?I d'ont have th problem with another project which is under .net 5
-
Hi,
maybe your navigation properties are not virtual. In that case, the proxy cannot replace them.public class TestProject { ... public virtual ICollection<TestItems> TestItems{get;set;} }