Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is .Include DbExtension for EF 6.0?

Was DbExtensions lib not included for EF 6.0? I have a generic repo that returns and IQueryable and I'd like to be able to call .Include(i => i.SomeEntity) on demaind when needed.

like image 219
Kirby Avatar asked May 13 '14 20:05

Kirby


2 Answers

I'm going to answer my own question. You don't make a reference to System.Data.Entity for version 6 to get the DbExtensions. You need to reference the EntityFramework itself and add using System.Data.Entity at the top of your cs file and the .Include() will be there.

like image 180
Kirby Avatar answered Sep 24 '22 10:09

Kirby


For EF 6.0 these functions are now available in System.Data.Entity.QueryableExtensions within EntityFramework.dll:

public static IQueryable Include(this IQueryable source, string path);

public static IQueryable<T> Include<T>(this IQueryable<T> source, string path);

public static IQueryable<T> Include<T, TProperty>(this IQueryable<T> source, Expression<Func<T, TProperty>> path);
like image 40
Stuart Smith Avatar answered Sep 24 '22 10:09

Stuart Smith