Entity Framework Core - Lazy Loading

前端 未结 7 398
野性不改
野性不改 2020-12-05 12:43

Bowing to my Visual Studios request, I started my latest project using Entity Framework Core (1.0.1)

So writing my database models as I always have using the \'virtu

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 13:28

    you can instaling this package for enable lazy loading in EF Core 2.1.

    Microsoft.EntityFrameworkCore.Proxies
    

    and then set this config in your ef dbContext

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
         => optionsBuilder
               .UseLazyLoadingProxies()
               .UseSqlServer("myConnectionString");
    

    "Notice" this package works only on EF Core 2.1 and above.

提交回复
热议问题