現在、完全に呼び出すことができません.Include()とintellisense(vscode)は存在しないと思われます。長い時間の後に今EFコア番号。DBsetのインクルード()メソッド
私は、この発見したウェブ検索:EF 5でのみ使用可能です.INCLUDEのみSystem.Data.Entitiesに存在することを示唆しているようだ
Not finding .Include() method in my EF implementing Generic repository
を、そして6.
私はどのようにしてEFコアのエンティティのリストプロパティを読み込むのですか?
HERESに私のコンテキスト
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にデータクラス:
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; }
}
それから私はのようなものです:.INCLUDEはEFコアに
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();
}
存在しませんか?
エラーメッセージに 'Ctrl + .'を打ってしまったので、Visual Studio 2015/2017は' Microsoft.EntityFrameworkCore'名前空間を使用してあなたを提案できますか? ;) – Tseng
私はUbuntuでVisual Studioコードを使用しています – user3801839
上記のコードを使用して 'Microsoft.EntityFrameworkCore;インテリセンスが見つからない場合でも、適切にコンパイルする必要があります。 – Smit