Entity Framework Core - Lazy Loading

前端 未结 7 393
野性不改
野性不改 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:23

    For EF Core 2.1 and above,

    Install:

     dotnet add package Microsoft.EntityFrameworkCore.Proxies --version 2.2.4 
    

    Then Update your Startup.cs file as indicated below.

    using Microsoft.EntityFrameworkCore.Proxies;
    
    
    
    services.AddEntityFrameworkProxies();
    services.AddDbContext(options =>
                {
                    options.UseSqlite(Configuration.GetSection("ConnectionStrings")["DefaultConnection"]);
                    options.UseLazyLoadingProxies(true);
                });
    

提交回复
热议问题