Update: Of course I tried to add using System.ComponentModel.DataAnnotations. It doesn't work.
Problem: I can't use Required attribute in asp.net vnext class library project.
Case:
1. Add asp.net vnext class library project with default settings.
2. Create class Human with string property Name.
3. Add Required attribute to the Name.
4. Get compilation error:
Error CS0246 The type or namespace name 'Required' could not be found (are you missing a using directive or an assembly reference?)
Below is my project.json:
{
"version": "1.0.0-*",
"dependencies": {
"System.ComponentModel.Annotations": ""
},
"frameworks": {
"aspnet50": {
},
"aspnetcore50": {
"dependencies": {
"System.Runtime": ""
}
}
}
}
Also I can use DataAnnotations in asp.net vnext, but not in vnext class library. Why?