Note that there are some explanatory texts on larger screens.

plurals
  1. POLazyLoadingEnabled setting doesn't seem to work in EF 5
    primarykey
    data
    text
    <p>I'm using EF Model first with POCO entities and with custom DbContexts. My problem is that setting <code>LazyLoadingEnabled=false</code> does not affect anything, navigation properties are still loaded. Below is my example simplified. </p> <p>The entity Program. A program can be part of other programs: </p> <pre><code>namespace Domain.Entities { using System; using System.Collections.Generic; public partial class Program { public Program() { this.Programs = new HashSet&lt;Program&gt;(); } public int Id { get; set; } public string Title { get; set; } public string Description { get; set; } public System.DateTime StartDate { get; set; } public System.DateTime EndDate { get; set; } public Nullable&lt;int&gt; ProgramId { get; set; } public virtual ICollection&lt;Program&gt; Programs { get; set; } public virtual Program OwnerProgram { get; set; } } } </code></pre> <p>The DbContext:</p> <pre><code>namespace Infrastructure.Model { public class ProgramContext : DbContext { public ProgramContext() : base("name=MyContainer") { Configuration.LazyLoadingEnabled = false; } public DbSet&lt;Program&gt; Programs { get; set; } } } </code></pre> <p>Here is how I use it:</p> <pre><code>private ProgramContext _dbContext = new ProgramContext(); // GET api/program public IEnumerable&lt;Program&gt; GetPrograms() { List&lt;Program&gt; list = _dbContext.Programs.ToList(); return list; } </code></pre> <p>With the above sample, EF still loads the Programs and OwnerProgram properties of the Program class. I have tried removing the virtual keywords, disabling the proxy creation and also verified that <code>LazyLoadingEnabled=false</code> on the Model itself.</p> <p>Am I missing something?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload