ApplyAutoInclude
Configures an entity navigation to be automatically included in EF Core queries. The method calls EF Core's navigation configuration for TEntity and enables AutoInclude on the provided navigation expression.
Use this method for navigations that should almost always be loaded with the entity. Avoid applying it to large collections or rarely needed navigations, because automatic includes affect every query for the entity unless explicitly ignored.
Usage
csharp
using Microsoft.EntityFrameworkCore;
using AlmightyShogun.EntityFrameworkCore.Utils;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyAutoInclude<User>(user => user.Profile);
}Parameters
navigation: Expression<Func<TEntity, object?>>
Navigation property that EF Core should automatically include whenever the entity is queried.
Type signature
csharp
public void ApplyAutoInclude<TEntity>(
Expression<Func<TEntity, object?>> navigation
) where TEntity : class;