Lazy Loading
dotnet add package Microsoft.EntityFrameworkCore.Proxiesservices.AddDbContext<TodoContext>(options => {
options.UseNpgsql(Configuration.GetConnectionString("Dev"));
options.UseLazyLoadingProxies();
});namespace TodoNetExample.Models
{
public class User : IdentityUser
{
public string Name { get; set; }
public virtual List<TodoList> TodoLists { get; set; }
}
}namespace TodoNetExample.Models
{
public class TodoList
{
public int Id { get; set; }
public string Name { get; set; }
public string UserId { get; set; }
public virtual User User { get; set; }
public virtual List<TodoItem> TodoItems { get; set; }
}
}Last updated