title: ViewModel for a model with a lot of properties?
body: <p>I plan to create a Asp.Net MVC app which contains edit/create pages for a large model with many-to-many relationship with other models. I found the <a href="https://stackoverflow.com/questions/11531769/saving-many-to-many-relationship-data-on-mvc-create-view">Saving Many to Many relationship data on MVC Create view</a> and plan to use it.</p>
  
  <p>In the example, the create page uses the following ViewModel.</p>
  
  <pre><code>public class UserProfileViewModel
  {
      public int UserProfileID { get; set; }
      public string Name { get; set; }
      public virtual ICollection&lt;AssignedCourseData&gt; Courses { get; set; }
  }
  </code></pre>
  
  <p>And the <code>UserProfile</code> model has only two properties so the ViewModel just duplicates all the properties.</p>
  
  <pre><code>public class UserProfile
  {
      public UserProfile()
      {
          Courses = new List&lt;Course&gt;();
      }
      public int UserProfileID { get; set; }
      public string Name { get; set; }
      public virtual ICollection&lt;Course&gt; Courses { get; set; }
  }
  </code></pre>
  
  <p>However, in my case, there will be a lot of properties (with data annotations), say 50 properties. Should the ViewModel duplicate all these properties (with data annotations too)? (looks ugly?) Or is there a better way?</p>
  
  <p><strong>Update</strong>
  Is it a good practice to define ViewModel as</p>
  
  <pre><code>public class UserProfileViewModel
  {
      public UserProfile UserProfile { get; set; } 
      .... // Other properties needed by the view.
  }
  </code></pre>
  
  <p>One shortcoming of this way is it expose all the properties in the Model even it's not needed in the view.</p>