I'm currently completely unable to call .Include() and intellisense (in vscode) doesn't seem to think it exists.
Now after a long time searching the web I've found this:
Not finding .Include() method in my EF implementing Generic repository
which seems to suggest that .Include exists only in System.Data.Entities, which is only available for EF 5 and 6.
So how do i eager load my list property for an entity in EF core?
heres my context
public class Database : DbContext { //Set new datasources like this: public DbSet<class> name { get; set; } public DbSet<Domain.Resource> Resources { get; set; } public DbSet<Domain.ResourceType> ResourceTypes { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseSqlite("Filename=./something.db"); } } Heres the data classes:
public class Resource { public int ResourceId { get; set; } public string Name { get; set; } public string Description { get; set; } public int ResourceTypeId { get; set; } public ResourceType ResourceType { get; set; } } public class ResourceType { public int ResourceTypeId { get; set; } public string Name { get; set; } public List<Resource> Resources { get; set; } } Then I do something like:
public List<ResourceType> GetAll() { var router = new Database(); var result = router.ResourceTypes.Include(rt => rt.Resources); //It's here there's absolutely no .Include method return result.ToList(); } Does .Include not exist in EF Core?
Ctrl+.on the error message, so Visual Studio 2015/2017 can suggest you usingMicrosoft.EntityFrameworkCorenamespace? ;)using Microsoft.EntityFrameworkCore;& write above code. Even if intellisense cannot find it, it should compile properly.