How to Fix Entity Framework Tolist Method Missing on Entity Class

If you want to use the ToList() method of an entity you need to import the namespace:
using System.Linq;, else the method will not appear.

Example
using System.Linq;

public class NorthWindDemo {
  private NorthwindEntities _entities = new NorthwindEntities();
  public ActionResult Index()
  {
    return View(_entities.ProductSet.ToList());
  }
}

1 Comments

Post a Comment

Post a Comment

Previous Post Next Post
NERV Open Source
Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.