You could use the MetadataType attribute. So let's suppose that EF spit at your face the following class which you cannot modify:
public partial class Foo
{
public string Bar { get; set; }
}
Now you could extend it since it is a partial class:
[MetadataType(typeof(FooMetadata))]
public partial class Foo
{
}
and then define the metadata:
public class FooMetadata
{
[Required]
[StringLength(10)]
public string Foo { get; set; }
}
Or, simply throw data annotations away and use a real validation framework such as FluentValidation.NET (which I use and strongly recommend) allowing you to express complex validation rules on your models in a fluent manner, has an excellent integration with ASP.NET MVC and also allows you to elegantly unit test your vaildation logic in isolation.