title: MVC two views in one model
body: <p>I'm trying to combine two views in one model.
  But I cannot get it too work!</p>
  
  <p>Can you help me?</p>
  
  <p>Models:</p>
  
  <pre><code> public class Player
  {
      public int playerID { get; set; }
  
      [Required]
      [Display(Name = "Spelernaam:")]
      public String playerName { get; set; }
  
      [Display(Name = "Team:")]
      public int teamID { get; set; }
  
      public virtual Team Team { get; set; }
  
      [Required]
      [Display(Name = "Waarde:")]
      public int playerValue { get; set; }
  }
  
  public class Team
  {
      public int teamID { get; set; }
  
      [Required]
      [Display(Name = "Teamnaam:")]
      public String teamName { get; set; }
  
      [Required]
      [Display(Name = "Teamwaarde:")]
      [Range(0, 100, ErrorMessage = "Waarde moet tussen de 0 en de 100 liggen")]
      public int teamValue { get; set; }
  
      [Required]
      [Display(Name = "Teambudget:")]
      [Range(0, 100000000, ErrorMessage = "Waarde moet tussen de 0 en de 100000000 liggen")]
      public int teamBudget { get; set; }
  
      [DefaultValue(0)]
      public int gamePoints { get; set; }
  
      public virtual ICollection&lt;Player&gt; Player { get; set; }
  }
  </code></pre>
  
  <p>I'm trying to get a list of players in a detail page of a team (scaffold). </p>
  
  <p>I have already tried to make a viewmodel and it looks like this:</p>
  
  <pre><code>public class PlayersPerTeam
  {
          public Team Team { get; set; }
          public Player Player { get; set; }
  }
  </code></pre>
  
  <p>But i think the controller is the problem </p>
  
  <p>Controller:</p>
  
  <pre><code>//
      // GET: /Team/Details/5
  
      public ActionResult Details(int id = 0)
      {
          Team team = db.Teams.Find(id);
          if (team == null)
          {
              return HttpNotFound();
          }
          return View(team);
      }
  </code></pre>
  
  <p>I hope you can help me with this!
  thanks alot!</p>
  
  <p>Error message:</p>
  
  <pre><code>The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.Team_B041141ED3453289BD09E3CAC14C091B831E03C09FDA76FF2D783BDDCE179358', but this dictionary requires a model item of type 'HerkansingsOpdracht.Models.PlayersPerTeam'.
  </code></pre>