I have created a class library project in VS2010 ultimate with .net 4.0 and Entity fwk-4.1.
After adding a ref to the Entity framework dll, I am not able to use the Data Annotation attributes like 'Required' on class properties.
Could you please let me know what is the solution?
Required
attribute is defined inside System.ComponentModel.DataAnnotations
namespace and is available in System.ComponentModel.DataAnnotations
assembly(dll)
1) Make sure to add a reference to System.ComponentModel.DataAnnotations
assembly(dll)
2) Add a using statement to import the System.ComponentModel.DataAnnotations
namespace in your class file.
using System.ComponentModel.DataAnnotations;
public class YourModel
{
[Required]
public string Name {set;get;}
}