0
votes

I have been developing my Models "model-first" by using the EDMX designer. I'm rather fond of it, but wondering how I can use this process to apply attributes, specifically DataAnnotations, to my model classes like so:

<DisplayFormat(ApplyFormatInEditMode:=True, DataFormatString:="{0:d}")>

I'm guessing that if I type those manually onto my model classes it will get overwritten whenever I update my EDMX file. What is the correct process here?

Thanks!

1

1 Answers

2
votes

At the risk of repeating myself formatting attributes such as DisplayFormat should be applied to the view models and not the models. Models contain reusable business logic. View models on the other hand are specifically designed for a given view, so the formatting should be done on those view models. A controller always passes a view model to a view.