I have an Entity Framework 4 model first layer, where I have a Product base class and then different classes that derive from the class. For each type of Product there is a Partial Class, and then each of the partial classes uses a buddy class for Data Annotations.
[MetadataType(typeof(Product_Validation))]
public partial class Product : EntityObject
{
private List<RuleViolation> ruleViolations = new List<RuleViolation>();
}
and then
public class Product_Validation
{
[DisplayName("Model Name")]
public string ModelName { get; set; }
[Required(ErrorMessage = "A description is required")]
[StringLength(2, ErrorMessage = "must be 2 or more")]
public string Description { get; set; }
}
The issue I have run into is that the base class validation (for product) is not happening server side in my ASP.NET MVC2 application. I have not tried client side yet.
The classes that are derived from Product, such as CD, do have the validation working. I know the wiring of the buddy class is working for the base product class because the Display Names I am using are being utilized. When I do my binding for the model I am using the derived class (CD).
Any ideas?
I looked at this SO Post but it did not seem to get me going.
Thanks!