When working with asp.net MVC 3, the default website which is installed from the template has an AccountModel. Within this, there are DataAnnotations for the password property and here the MinimumLength of the StringLength is set.
However, within the .NET framework Membership provider, you can set the minRequiredPasswordLength via the web.config file.
Now if you were to set the minRequiredPasswordLength to say 6, yet have the AccountModel.password MinimumLength set to 1, then you would not be able to register if your password is only 1 character in length. Same the other way around, minRequiredPasswordLength is 1 and MinimumLength is 6 will not allow registration.
So to me this is a bit backwards. If an installation of the app does not require the a longer password length, then you have to change this in the model.
DataAnnotations have to be constant values from what I have read, so is there a way to link these two? Ideally I would like to only have to change the value in the web.config and not have to worry about rebuilding projects.
Edit
I noticed after looking into this more that Pre MVC 3 Tools Update, the Project Template actually contained a DataAnnotation which linked the Membership minRequiredPasswordLength property from the web.config to the AccountModel
Blogged about it here: http://timjames.me/mvc-3-password-length-dataannotation
The short answer is that you can’t. DataAnnotations are statically compiled into the assembly, and cannot be changed at runtime.
You could create a custom annotation that looked up the length, or use a remote validation to validate against the value in the web.config. But this would not be using the standard Length attribute.