mvc application reference error

I saw this ASP.NET MVC example  on using jqgrid

In this example they are using Lind database model.

I switched up the data model in my example to use Entity Database First model. So my data model is called HaackOverflowEF.edmx.

The example code in the link above was done using Visual Studio 2010.

So when I used Visual Studio 2010 and ran my application, it works just fine.  
My Visual Studio 2010 directory looks like this:

my visual studio 2010 directory
The code for my HomeController.cs in my Visual Studio 2010 application looks like this:

// The example is a modification of the example created by Phil Haack
// see
using System.Linq;
using System.Web.Mvc;
using jqGridWeb.Models;
using System.Data.Objects;
using System.Web.Script.Serialization;
using System.Collections.Generic;
using System.Text;
using System;
using System.Reflection;

namespace jqGridWeb.Controllers
    // to send exceptions as json we define [HandleJsonException] attribute
    public class ExceptionInformation {
        public string Message { get; set; }
        public string Source { get; set; }
        public string StackTrace { get; set; }
    public class HandleJsonExceptionAttribute : ActionFilterAttribute {
        // next class example are from the
        public override void OnActionExecuted(ActionExecutedContext filterContext) {
            if (filterContext.HttpContext.Request.IsAjaxRequest() && filterContext.Exception != null) {
                filterContext.HttpContext.Response.StatusCode =

                var exInfo = new List<ExceptionInformation>();
                for (Exception ex = filterContext.Exception; ex != null; ex = ex.InnerException) {
                    PropertyInfo propertyInfo = ex.GetType().GetProperty ("ErrorCode");
                    exInfo.Add(new ExceptionInformation() {
                        Message = ex.Message,
                        Source = ex.Source,
                        StackTrace = ex.StackTrace
                filterContext.Result = new JsonResult() {Data=exInfo};
                filterContext.ExceptionHandled = true;

    public class Filters {
        public enum GroupOp {
        public enum Operations {
            eq, // "equal"
            ne, // "not equal"
            lt, // "less"
            le, // "less or equal"
            gt, // "greater"
            ge, // "greater or equal"
            bw, // "begins with"
            bn, // "does not begin with"
            //in, // "in"
            //ni, // "not in"
            ew, // "ends with"
            en, // "does not end with"
            cn, // "contains"
            nc  // "does not contain"
        public class Rule {
            public string field { get; set; }
            public Operations op { get; set; }
            public string data { get; set; }

        public GroupOp groupOp { get; set; }
        public List<Rule> rules { get; set; }
        private static readonly string[] FormatMapping = {
            "(it.{0} = @p{1})",                 // "eq" - equal
            "(it.{0} <> @p{1})",                // "ne" - not equal
            "(it.{0} < @p{1})",                 // "lt" - less than
            "(it.{0} <= @p{1})",                // "le" - less than or equal to
            "(it.{0} > @p{1})",                 // "gt" - greater than
            "(it.{0} >= @p{1})",                // "ge" - greater than or equal to
            "(it.{0} LIKE (@p{1}+'%'))",        // "bw" - begins with
            "(it.{0} NOT LIKE (@p{1}+'%'))",    // "bn" - does not begin with
            "(it.{0} LIKE ('%'+@p{1}))",        // "ew" - ends with
            "(it.{0} NOT LIKE ('%'+@p{1}))",    // "en" - does not end with
            "(it.{0} LIKE ('%'+@p{1}+'%'))",    // "cn" - contains
            "(it.{0} NOT LIKE ('%'+@p{1}+'%'))" //" nc" - does not contain
        internal ObjectQuery<T> FilterObjectSet<T> (ObjectQuery<T> inputQuery) where T : class {
            if (rules.Count <= 0)
                return inputQuery;

            var sb = new StringBuilder();
            var objParams = new List<ObjectParameter>(rules.Count);

            foreach (Rule rule in rules) {
                PropertyInfo propertyInfo = typeof (T).GetProperty (rule.field);
                if (propertyInfo == null)
                    continue; // skip wrong entries

                if (sb.Length != 0)

                var iParam = objParams.Count;
                sb.AppendFormat(FormatMapping[(int)rule.op], rule.field, iParam);

                ObjectParameter param;
                switch (propertyInfo.PropertyType.FullName) {
                    case "System.Int32":  // int
                        param = new ObjectParameter ("p" + iParam, Int32.Parse (;
                    case "System.Int64":  // bigint
                        param = new ObjectParameter ("p" + iParam, Int64.Parse (;
                    case "System.Int16":  // smallint
                        param = new ObjectParameter ("p" + iParam, Int16.Parse (;
                    case "System.SByte":  // tinyint
                        param = new ObjectParameter ("p" + iParam, SByte.Parse (;
                    case "System.Single": // Edm.Single, in SQL: float
                        param = new ObjectParameter ("p" + iParam, Single.Parse (;
                    case "System.Double": // float(53), double precision
                        param = new ObjectParameter ("p" + iParam, Double.Parse (;
                    case "System.Boolean": // Edm.Boolean, in SQL: bit
                        param = new ObjectParameter ("p" + iParam,
                            String.Compare(, "1", StringComparison.Ordinal) == 0 ||
                            String.Compare(, "yes", StringComparison.OrdinalIgnoreCase) == 0 ||
                            String.Compare(, "true", StringComparison.OrdinalIgnoreCase) == 0?
                        // TODO: Extend to other data types
                        // binary, date, datetimeoffset,
                        // decimal, numeric,
                        // money, smallmoney
                        // and so on

                        param = new ObjectParameter ("p" + iParam,;
                objParams.Add (param);

            ObjectQuery<T> filteredQuery = inputQuery.Where (sb.ToString ());
            foreach (var objParam in objParams)
                filteredQuery.Parameters.Add (objParam);

            return filteredQuery;

    public class HomeController : Controller
        public ActionResult Index()
            ViewData["Message"] = "Welcome to ASP.NET MVC!";
            return View();

        public JsonResult DynamicGridData(string sidx, string sord, int page, int rows, bool _search, string filters)

            var context = new HaackOverflowEntities();
            var serializer = new JavaScriptSerializer();
            Filters f = (!_search || string.IsNullOrEmpty (filters)) ? null : serializer.Deserialize<Filters> (filters);
            ObjectQuery<Question> filteredQuery =
                (f == null ? context.Questions : f.FilterObjectSet (context.Questions));
            filteredQuery.MergeOption = MergeOption.NoTracking; // we don't want to update the data
            var totalRecords = filteredQuery.Count();

            var pagedQuery = filteredQuery.Skip ("it." + sidx + " " + sord, "@skip",
                                                new ObjectParameter ("skip", (page - 1) * rows))
                                         .Top ("@limit", new ObjectParameter ("limit", rows));
            // to be able to use ToString() below which is NOT exist in the LINQ to Entity
            var queryDetails = (from item in pagedQuery
                                select new { item.Id, item.Votes, item.Title }).ToList();

            return Json(new {
                            total = (totalRecords + rows - 1) / rows,
                            records = totalRecords,
                            rows = (from item in queryDetails
                                    select new[] {

        public ActionResult About ()
            return View();

Open in new window

Like i said, my Visual Studio 2010 application ran just fine.

So since i'm using Visual Studio 2013 Ultimate , I tried to open my Visual Studio 2010 project with it but it would not let me upgrade it and said project not supported.

So then I figured I would create the exact same project from scratch in Visual Studio 2013 instead of converting it.

So then my Visual Studio 2013 ASP.NET MVC application looks like this and I'm using Entity Framework 6.

I have the exact same code and directory structure as in my Visual Studio 2010 project. I re-created the entity model in this visual studio 2013 project.

But now I'm getting one error. The image below shows the error.

error message
Anyone know why I'm getting this error or am I missing something?

The code is the same in both projects but I'm getting this one error.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

maqskywalkerAuthor Commented:
I did a little more research.

So I created a different jqgrid exampl. This time i did a ASP.NET Web Forms example.

So I did my example using Visual Studio 2010 , C#, Web Forms and targeting .NET 4.
In my project i installed Entity Framework 6.1.1 by typing this at the console manager.

Install-Package EntityFramework

So after I Installed Entity Framework 6.1.1 in my Visual Studio 2010 project I then created Northwind.edmx

My jqgrid just binds the Employees table from that model.
So then I ran my project and it works just fine.

This is what my model in solution explorer looks like:

my Northwind.edmx model in Visual Studio 2010 Solution Explorer
So then I created the exact same example in Visual Studio 2013 and I also used Entity Framework 6.1.1.

But I noticed one thing, in my Visual Studio 2013 when I created my Northwind.edmx model.  When I look at the structure in Solution Explorer it looks a little different than it does in Visual Studio 2010.

This is what it looks like in Visual Studio 2013:

my Northwind.edmx model in Visual Studio 2013 Solution Explorer
If you look at my picture of Northwind.edmx in Visual Studio 2010 above, that one has some items that containt ObjectSet  in it.
Whereas my Visual Studio 2013 model in solution explorer doesn't have these items and I believe that is why I'm getting the exact same error in both of my visual studio 2013 examples.

Both my examples work just when when I use EF 6.1.1 in Visual Studio 2010 but I get this same error in both my example when I use EF 6.1.1 in Visual Studio 2013.

Anyone know why I'm getting this error? How do i fix it?

The line of code I'm getting the error is this.

            ObjectQuery<Employee> filteredQuery =
                f == null ? context.Employees : f.FilterObjectSet(context.Employees);

Do I have to change the syntax on this line?
käµfm³d 👽Commented:
Your original code was using type inference. For whatever reason, 2013 cannot determine the types to plug in to the generic method's type parameters (during compilation). Just specify them yourself by including the angle brackets and an appropriate type.


...  f.FilterObjectSet<[insert type her]>(context.Questions));

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maqskywalkerAuthor Commented:
I'm confused, so what would i type inside the < >   ?

My Entity Model called Northwind.edmx just has the Employees table of the Northwind database modeled in the diagram.

The only columns I'm using in my grid are  EmployeeID which is Integer, LastName which is nvarchar(20), FirstName which is nvarchar(10) and Title which is nvarchar(30)

So would my line look like this? what would I type inside  the angle brackets?

ObjectQuery<Employee> filteredQuery =
                f == null ? context.Employees : f.FilterObjectSet<??????????>(context.Employees);

I saw this link, with possible solution, but that doesn't make sense to me.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.