title: Moving the models in mvc 3 from web project to class library
body: <p>I am creating an application in MVC3. On creating the application, there were three folders created in the Web Project:</p>
  
  <ol>
  <li>Controllers</li>
  <li>Models</li>
  <li>Views</li>
  </ol>
  
  <p>I want to implement a layered architechture, hence i created a class library project which will have the business and repository layers.</p>
  
  <p>I moved the models from the web project to class library project so that i can use the models in the business layer.
  The model classes contain the required properties and their validations as specified below:</p>
  
  <pre><code>public class ChangePasswordModel
  {
      [Required]
      [DataType(DataType.Password)]
      [Display(Name = "Current password")]
      public string OldPassword { get; set; }
  
      [Required]
      [ValidatePasswordLength]
      [DataType(DataType.Password)]
      [Display(Name = "New password")]
      public string NewPassword { get; set; }
  
      [DataType(DataType.Password)]
      [Display(Name = "Confirm new password")]
      [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
      public string ConfirmPassword { get; set; }
  }
  
  public sealed class ValidatePasswordLengthAttribute : ValidationAttribute, IClientValidatable
  </code></pre>
  
  <p>I also have a class in the same file above to validate my password length which implements the interface <code>IClientValidatable</code></p>
  
  <p>I am facing two problems:</p>
  
  <ol>
  <li>I am unable to use the CompareAttribute as well as the interface <code>IClientValidatable</code>. Both of the mentioned classes area apart of System.Web.MVC. I have added the reference to the <code>System.Web.MVC</code> dll to my class library.</li>
  </ol>
  
  <p>In both the cases i am unable to resolve the issue. 
  The resharper mentions the error relating to circular dependencies.</p>
  
  <p>Can i not use the <code>System.Web.Mvc</code> reference and use the classes and validations provided in a class library?
  Additionally, the validations provided in <code>System.ComponentModel.DataAnnotations</code> do not create an issue.</p>
  
  <p>I am unable to build the solution and hence cannot proceed with the development.
  Any solutions and suggestions are welcome.</p>