Quick question...
If I put a notation in the Interface...
Say [Required]
can I ommit that notation in the C# class for the property?
i.e. can
The Data Annotation won't work but I don't know why.
If you are using EF code first you can use Fluent API to force this behavior when creating your database. This is a workaround, not a real solution because only your database will check the constraint, not EF or any other system working with Data Annotation (well I suppose).
I did it with
public partial class MyDbContext : DbContext
{
// ... code ...
protected override void OnModelCreating(DbModelBuilder dbModelBuilder)
{
dbModelBuilder.Types().Configure(y => y.Property(e => e.Bar).IsRequired());
}
}
Telling the system that when it recognize a class implementing IFoo you configure the property to IsRequired.