You can use the following methods to add related meta-validation attributes to the model so that the entity's validation properties are not replaced by the model, such as EF or other tools, that are automatically generated.
Using System.ComponentModel.DataAnnotations;
Namespace IDO. Entities
{
[Metadatatype (typeof (Customermetadata))]
Partial class Customer
{
}
public class Customermetadata
{
[Required (errormessage = "{0} cannot be empty")]
public string Name {get; set;}
[Required (errormessage = "{0} cannot be empty")]
[Stringlength (one, errormessage = "{0} cannot exceed {1} bits")]
[RegularExpression (@ "^1[3458]\d{9}$", errormessage = "{0} Invalid format")]
public string Mobile {get; set;}
[RegularExpression (@ "^ [\w-\.] +) @ ((\[[0-9]{1,3}\. [0-9] {1,3}\. [0-9] {1,3}\.) | ([\w-]+\.) +)) ([a-za-z]{2,4}| [0-9] {1,3}) (\]?) $ ", errormessage =" {0} format is invalid ")]
public string e-mail {set; get;}
[Required (errormessage = "{0} cannot be empty")]
public string Title {get; set;}
}
}
MVC4 + EF Adds a separate validation attribute for the model