title: Two Models or One View?
body: <p>I want to use two models in one View. Here is my code:</p>
  
  <pre><code>public class Users {
     public int id { get; set; }
     public string adSoyad { get; set; }
     public string email { get; set; }
     public int puan { get; set; }
  }
  public class admin {
     public int id { get; set; }
     public string name { get; set; }
  }
  
  public class mainmodel {
     public Users Users { get; set; }
     public admin admin { get; set; }
  }
  </code></pre>
  
  <p>I can use it to delete, edit, and create views. But I get errors in my index view:</p>
  
  <pre><code>@model IEnumerable&lt;donemProje.Models.mainmodel&gt;
  </code></pre>
  
  <p>What can I do?</p>
  
  <p>Edit--
  i try  this in index  view </p>
  
  <pre><code>@model donemProje.Models.mainmodel
  
  
  @foreach (var item in Model.Users)
  {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt;item.adSoyad)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.email)
  </code></pre>
  
  <p>and  get  this error </p>
  
  <p>Compiler Error Message: CS1579: foreach statement cannot operate on variables of type 'donemProje.Models.Users' because 'donemProje.Models.Users' does not contain a public definition for 'GetEnumerator'</p>
  
  <p>int this line</p>
  
  <p>Line 34: <code>@foreach (var item in Model.Users)</code></p>