Reputation: 85
This is probably a really silly question, but I can't seem to find an answer for it. In my model classes, I always have to add in a couple of lines of using statements - for example
using System.ComponentModel.DataAnnotations
Is there any way to have that namespace included automatically in every model class so I don't have to type it in every time?
Thanks
Upvotes: 1
Views: 1196
Reputation: 12966
This namespace is used for the validation attributes. I tend to write out a property in my class, and add an attribute, e.g. RequiredAttribute
.
I type [Required
, and after the d
Visual Studio puts a little square at the bottom of the line. Hit Ctrl + . and you'll get a context menu that will add the required using
statement for you. So you don't ever have to type it out by hand.
Upvotes: 0
Reputation: 4701
Your question is similar to this one The answer in that question is you have 4 options:
see more comments on the question
Upvotes: 3
Reputation: 3262
To achieve that you will need to create custom visual studio item template:
How to create a Visual Studio Item Template
Upvotes: 0