IQueryable<T> does not contain a definition for 'Include' and no extension method 'Include'
I'm trying to use Include extension on IQueryable set, but I have the following issue:
Error 1 'System.Linq.IQueryable<.Model.InsuranceCaseType>' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Linq.IQueryable<.Model.InsuranceCaseType>' could be found (are you missing a using directive or an assembly reference?)
My code:
var allCaseTypes = Uow.InsuranceCaseType.GetAll().Include(a=>a.Geos);
Method GetAll()
returns - IQueryable<.Model.InsuranceCaseType>
I have in scope the following namespaces:
using System.Collections;
using System.Collections.Generic;
using System;
using System.Data;
using System.Linq;
using System.Data.Entity;
using System.IO;
using System.Web;
using System.Web.Mvc;
Solution 1:
Include
is not an extension method on Queryable
, so it doesn't come together with all the usual LINQ methods. If you are using Entity Framework, you need to import the corresponding namespace:
using System.Data.Entity;
Solution 2:
If you are using .Net core version then you need to install: Microsoft.EntityFrameworkCore nuget package.
And then:
using Microsoft.EntityFrameworkCore;