title: MVC View doesn't get ID of model
body: <p>I'm new in MVC and trying my first project.</p>
  
  <p>I have a database with several tables and I want to create controller for each table.</p>
  
  <p>I started with Disc that has ID and DiscNum, both are of type int.</p>
  
  <p>This is the controller I created:</p>
  
  <pre><code>public class DiscController : Controller
  {
      // GET: Disc
      public ActionResult Index()
      {
          var entities = new MovieDBEntities();
  
          return View(entities.Disc);
      }
  
      // GET: Disc/Details/5
      public ActionResult Details(int id)
      {
          return View();
      }
  
      // GET: Disc/Create
      public ActionResult Create()
      {
          return View();
      }
  
      // POST: Disc/Create
      [HttpPost]
      public ActionResult Create(FormCollection collection)
      {
          try
          {
              // TODO: Add insert logic here
  
              return RedirectToAction("Index");
          }
          catch
          {
              return View();
          }
      }
  
      // GET: Disc/Edit/5
      public ActionResult Edit(int id)
      {
          return View();
      }
  
      // POST: Disc/Edit/5
      [HttpPost]
      public ActionResult Edit(int id, FormCollection collection)
      {
          try
          {
              // TODO: Add update logic here
  
              return RedirectToAction("Index");
          }
          catch
          {
              return View();
          }
      }
  
      // GET: Disc/Delete/5
      public ActionResult Delete(int id)
      {
          return View();
      }
  
      // POST: Disc/Delete/5
      [HttpPost]
      public ActionResult Delete(int id, FormCollection collection)
      {
          try
          {
              // TODO: Add delete logic here
  
              return RedirectToAction("Index");
          }
          catch
          {
              return View();
          }
      }
  }
  </code></pre>
  
  <p>And this is my Index.cshtml file:</p>
  
  <pre><code>@model IEnumerable&lt;Movies.Models.Disc&gt;
  
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.DiscNum)
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  
  @foreach (var item in Model) {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.DiscNum)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
              @Html.ActionLink("Details", "Details", new { id=item.ID }) |
              @Html.ActionLink("Delete", "Delete", new { id=item.ID })
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  
  &lt;/table&gt;
  </code></pre>
  
  <p>Everything is going fine but the details View, all the other views are OK.</p>
  
  <p>This is my Details view:</p>
  
  <pre><code>@model Movies.Models.Disc
  
  @{
      ViewBag.Title = "Details";
  }
  
  &lt;h2&gt;Details&lt;/h2&gt;
  
  &lt;div&gt;
      &lt;h4&gt;Disc&lt;/h4&gt;
      &lt;hr /&gt;
      &lt;dl class="dl-horizontal"&gt;
          &lt;dt&gt;
              @Html.DisplayNameFor(model =&gt; model.DiscNum)
          &lt;/dt&gt;
  
          &lt;dd&gt;
              @Html.DisplayFor(model =&gt; model.DiscNum)
          &lt;/dd&gt;
  
      &lt;/dl&gt;
  &lt;/div&gt;
  &lt;p&gt;
      @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
      @Html.ActionLink("Back to List", "Index")
  &lt;/p&gt;
  </code></pre>
  
  <p>When I try to open it I get an error that says: System.NullReferenceException. 
      The error is in the row that says: @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |</p>
  
  <p>Model is probably null.</p>
  
  <p>How do i fix it?</p>
  
  <p>Can someone give me a hand?</p>
  
  <p>Thank you in advance!</p>