title: CS0118 error in controller from model in asp.net
body: <p>I'm creating a database with the entity framework, I created the first entity as a carlot and the second car which will list the cars in the respective lots. I keep thinking something is wrong with my model ... here is following model </p>
  
  <pre><code>namespace CarLot.Models
  {
      using System;
      using System.Collections.Generic;
      using System.Data.Entity;
      using System.Linq;
  
      public class CarModel : DbContext
      {
   public CarModel()
              : base("name=CarModel")
          {
          }
  
          // Add a DbSet for each entity type that you want to include in your model. For more information 
          // on configuring and using a Code First model, see http://go.microsoft.com/fwlink/?LinkId=390109.
  
          public DbSet&lt;CarLot&gt; CarLots { get; set; }
          public DbSet&lt;Car&gt; Cars { get; set; }
      }
  
      public class CarLot
      {
          //Primary Key
          public int CarLotID { get; set; }
          public string Name { get; set; }
  
          public string Section { get; set; }
  
          public virtual ICollection&lt;Car&gt; Cars { get; set; }
      }
  
      public class Car
      {
          public int CarId { get; set; }
  
          public string Make { get; set; }
  
          public string Model { get; set; }
  
          public int Year { get; set; }
  
          public int Price { get; set; }
  
          public bool isNew { get; set; }
  
  
          //foreign key
          public int CarLotID { get; set; }
          public virtual CarLot Carlot { get; set; }
      }
  
  
  }
  </code></pre>
  
  <p>I proceeded to scaffold the controller for Cars, that does not show any errors. 
  but not my carlot, this is the following CarLot file... its giving me the CS0118 error with CarLot as commented below, 6 following CarLot giving me the CS0118 which states "CarLot is a namespace but is used as a type"</p>
  
  <pre><code>sing System;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Net;
  using System.Web;
  using System.Web.Mvc;
  using CarLot.Models;
  
  namespace CarLot.Controllers
  {
      public class CarLotsController : Controller
      {
          private CarModel db = new CarModel();
  
          // GET: CarLots
          public ActionResult Index()
          {
              return View(db.CarLots.ToList());
          }
  
          // GET: CarLots/Details/5
          public ActionResult Details(int? id)
          {
              if (id == null)
              {
                  return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
              }
              // It is giving me the CS0118 error with the following CarLot
  
              CarLot carLot = db.CarLots.Find(id);
              if (carLot == null)
              {
                  return HttpNotFound();
              }
              return View(carLot);
          }
  
          // GET: CarLots/Create
          public ActionResult Create()
          {
              return View();
          }
  
          // POST: CarLots/Create
          // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
          // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Create([Bind(Include = "CarLotID,Name,Section")] CarLot carLot)
          {
              if (ModelState.IsValid)
              {
                  db.CarLots.Add(carLot);
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
  
              return View(carLot);
          }
  
          // GET: CarLots/Edit/5
          public ActionResult Edit(int? id)
          {
              if (id == null)
              {
                  return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
              }
              CarLot carLot = db.CarLots.Find(id);
              if (carLot == null)
              {
                  return HttpNotFound();
              }
              return View(carLot);
          }
  
          // POST: CarLots/Edit/5
          // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
          // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult Edit([Bind(Include = "CarLotID,Name,Section")] CarLot carLot)
          {
              if (ModelState.IsValid)
              {
                  db.Entry(carLot).State = EntityState.Modified;
                  db.SaveChanges();
                  return RedirectToAction("Index");
              }
              return View(carLot);
          }
  
          // GET: CarLots/Delete/5
          public ActionResult Delete(int? id)
          {
              if (id == null)
              {
                  return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
              }
              CarLot carLot = db.CarLots.Find(id);
              if (carLot == null)
              {
                  return HttpNotFound();
              }
              return View(carLot);
          }
  
          // POST: CarLots/Delete/5
          [HttpPost, ActionName("Delete")]
          [ValidateAntiForgeryToken]
          public ActionResult DeleteConfirmed(int id)
          {
              CarLot carLot = db.CarLots.Find(id);
              db.CarLots.Remove(carLot);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
  
          protected override void Dispose(bool disposing)
          {
              if (disposing)
              {
                  db.Dispose();
              }
              base.Dispose(disposing);
          }
      }
  }
  </code></pre>