i have a mvc web projec开发者_开发技巧t and i'm using linq to sql i'm using dataannotaion like this
public class ClientValidation
{
[Required]
public string name1st { get; set; }
}
then in the linq class i add that above client class
[global::System.Data.Linq.Mapping.TableAttribute(Name = "dbo.Client")]
[MetadataType(typeof(ClientValidation))]
public partial class Client : INotifyPropertyChanging, INotifyPropertyChanged
{
}
every thing is going ok the question is when i re generate the linq when i add table or change any thing in database i need to rewrite [MetadataType(typeof(ClientValidation))] is there any other method to enable me regenerate the model and keep the data annotation as it
Write a partial class in another file with empty body and just annotate that with your attribute, partial class
es and partial method
s designed for this situations where you want to add a functionality to an autogenerated class or method.
精彩评论