title: Code First - Validating Password and also Hashing with same entity
body: <ol>
  <li>Code First</li>
  <li>Entity Framework</li>
  <li>C# Visual Studio 2012</li>
  </ol>
  
  <p>I have a user account entity that validates a password against a regular expression</p>
  
  <p>is there an event I can use that will convert the password to a hashed value just before saving to the database? </p>
  
  <p>My problem is that if I hash the password first then I cant validate using this entity.</p>
  
  <p>I have thought about extracting the validation to a different area and only saving the the hashed value to the entity.</p>
  
  <p>The current flow is as follows</p>
  
  <ol>
  <li>User enters new account details</li>
  <li>User Account entity created</li>
  <li>Entity validated using dataannotations</li>
  <li>Password hashed</li>
  <li>Entity saved to database</li>
  </ol>
  
  <p>Can someone help me please with thoughts on where to place the password hashing</p>