Wondering if Entity Framework 5 supports unique constraints on entity properties? If so, how can I specify that a property should be unique?
Well i was looking for solution and finally i found it. when you generate migration in code you can create unique key
CreateTable(
"dbo.TaBLE",
c => new
{
Id = c.Int(nullable: false, identity: true),
Date = c.DateTime(nullable: false),
Meter_Id = c.Int(),
})
.PrimaryKey(t => t.Id)
.Index(t => new {t.Meter_Id, t.Date}, true);
Validation before insert you can do on BLL level, so i think it can solve your problem.