I'm having a really tough time finding guidance on how to AVOID including navigation properties in EF Core in a database-first approach. Using unmodified scaffolded web API controllers in Visual Studio, I have an entity that looks like this (simplified for example):
public partial class ProjectPhase
{
public ProjectPhase()
{
Projects = new HashSet<Project>();
}
public int PhaseId { get; set; }
public string PhaseName { get; set; }
public virtual ICollection<Project> Projects { get; set; }
}
My request is the default scaffolded HTTP GET request:
// GET: api/Phases
[HttpGet]
public async Task<ActionResult<IEnumerable<ProjectPhase>>> GetPhases ()
{
return await _context.ProjectPhases.ToListAsync();
}
The return value looks like this:
...{
"phaseId": 1,
"phaseName": "Pilot",
"projects": []
},...
I want this request to NOT include projects
in the returned object. How do I do this?