Pass Objects from a controller to a view MVC
<p>I started in a new job, we must create an app using MVC 5, i have no experience in .NET so I not sure if I am using the best practice.</p>

<p>I have 2 models ClassRom and Students, </p>

<pre><code>public class Student
{
    public int ID { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
}

 public class ClassRom
{
    public int ID { get; set; }
    public string Name { get; set; }
}
</code></pre>

<p>I am passing a ICollection&lt;> from a controller to a views using ViewBag</p>

<pre><code>IList&lt;ClassRom&gt; classes = db.Classes.ToList();
IList&lt;Student&gt; students = db.Students.ToList();
ViewBag.classes = classes;
ViewBag.students = students;
return View();
</code></pre>

<p>And using the data in a view</p>

<pre><code>&lt;div&gt;
@foreach (var student in ViewBag.students)
{
    &lt;div&gt;@student.Name&lt;/div&gt;
    &lt;div&gt;@student.Age&lt;/div&gt;
}  
</code></pre>

<p></p>

<p>It works pretty well for what I need, anyway if I add a Scaffolded Controller, it will create something like this:</p>

<pre><code>public ActionResult Index()
    {
        return View(db.Students.ToList());
    }
</code></pre>

<p>And the view </p>

<pre><code>@model IEnumerable&lt;School.Models.Student&gt;
@foreach (var item in Model) {
&lt;tr&gt;
    &lt;td&gt;
        @Html.DisplayFor(modelItem =&gt; item.Name)
    &lt;/td&gt;
    &lt;td&gt;
        @Html.DisplayFor(modelItem =&gt; item.Age)
    &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;
</code></pre>

<p>}</p>

<p>My question is, Am i doing it wrong? should I use @model IEnumerable instead of ViewBag? </p>