How to retain the data annotations or class during modify a table in the database
If we use [MetadataType(typeof(ConceptMetadataSource))] to attach a MetadataSource file which contains all the data annotations like [HiddenInput(DisplayValue = false)] or [Display(Name = "Title")]. The data annotations will be wiped out each time the entity classes are regenerated as the code will be regenerated once we modify a table in the database
Solution:
All you have to do is create another partial class and use Metadatatype attribute
Create a metadata class in models as below…
Create a Partial class for the metadata in models as below…
The new partial class can be created in a different folder

Comments
Post a Comment