I have a project called Model. All of my entities are in that project generated by EF Code first.
Public Partial Class Person
{
...
}
I don't want to touch my generated classes so I can create a partial class and add MetadataType
attribute to it.
[MetadataType(typeof(Person_Metadata))]
public partial class Person
{
}
And here is my buddy class.
[Bind(Exclude="PersonID")]
public class Person_Metadata
{
[Display(Name:="First name")]
public string FirstName { get; set; }
[Display(Name:="Last name")]
public string LastName { get; set; }
}
The problem is, I want to move my buddy class to another assembly.
Model project has no reference to it so [MetadataType(typeof(Person_Metadata))]
gives an error because it has no reference to Person_Metadata
class.
I can use FluentValidation for validation part (and it works great), but what about other Metadata like: Display
Attribute ?
I have also found this question: Adding DataAnnotation to class when using FluentValidation about managing MetaData with FluentValidation engine, but that looks like a long way to go and I prefer using data annotation attributes