title: MinLength constraint on ICollection fails, Entity Framework
body: <p>This is the datamodel I have:</p>
  
  <pre><code>public class Team
  {
      [Key]
      public int Id { get; set;} 
      [Required]
      public string Name { get; set; }
  
      [MinLength(1)]
      public virtual ICollection&lt;User&gt; Users { get; set; }
  }
  </code></pre>
  
  <p>My issue is that when I later try to create a new Team (that has one user) I get the following issue when the context is saving.</p>
  
  <blockquote>
    <p>An unexpected exception was thrown during validation of 'Users' when invoking System.ComponentModel.DataAnnotations.MinLengthAttribute.IsValid. See the inner exception for details.</p>
  </blockquote>
  
  <p>The inner exception is the following:</p>
  
  <blockquote>
    <p>{"Unable to cast object of type 'System.Collections.Generic.List`1[MyNameSpace.Model.User]' to type 'System.Array'."}</p>
  </blockquote>
  
  <p>Here is the code for the actual saving (which for now is in the controller):</p>
  
  <pre><code>        if (ModelState.IsValid)
          {
              team.Users = new List&lt;User&gt;();
              team.Users.Add(CurrentUser);//CurrentUser is a property that gives me the currently active User (MyNamespace.Model.User).
              DB.Teams.Add(team);//DB is a DbContext object that holds DbSets of all my models
              DB.SaveChanges();
              return RedirectToAction("Index");
          }
  </code></pre>
  
  <p>So, what's going on here? Am I doing something wrong, or is there something else happening?</p>