I am trying to add check constraint in database side through Entity Framework code first approach,
ALTER TABLE [dbo].[YOUR_TABLE]
ADD CONSTRAINT [MinLengthConstraint] CHECK (DATALENGTH([your_column]) > 2)
I am decorating entity property with String Length & Min Length, but the check constraint is not applied to database table. Please suggest!
[StringLength(100), MinLength(2)]
public string StudentName { get; set; }