Is it possile to create a DbQuery from model with lazy-loaded navigation properties? When I tried to do so, I got the following error
getting value from 'Prefix' on 'Castle.Proxies.ExtendedStudentProxy --> Unable to track an instance of type 'ExtendedStudent' because it is a query type, Only entity types may be tracked.
I thought that DbQuery are read only so aren't they supposed to not be tracked as a default behavior? Am I wrong?
This this a sample of the code I used:
models:
public class ExtendedStudent {
public string FirsName {get; set;}
public virtual Prefix Prefix {get; set;}
}
public class Prefix {
public int Id {get; set;}
public string Name {get; set;}
}
Startup.cs
builder.AddDbContext<ApplicationDbContext>( b => b.UseLazyLoadingProxies()
.UseSqlServer(connectionString));
ApplicationDbContext.cs
public class ApplicationDbContext {
...
public DbSet<Proxy> Proxies {get; set;}
public DbQuery<ExtendedStudent> ExtendedStudents {get; set;}
...
}