The better solution is indeed to use a Hash.
But a general pattern for injecting some logic:
public class User
{
// the mapped-to-column property
protected virtual string PasswordStored
{
get ;
set ;
}
[NotMapped]
public string Password
{
get { return Decrypt(PasswordStored); }
set { PasswordStored = Encrypt(value); }
}
}
Instead of [NotMapped]
you can also use the fluent API to keep EF from storing it directly.