I have the following model:
public class Blog { public int BlogID { get; set; } public int CategoryID { get; set; } [MaxLength(70)] [Required] public string BlogTitle { get; set; } [Column(TypeName="ntext")] public string BlogContent { get; set; } }
I manually set the BlogContent field to ntext (16 bytes) in the SQL CE4 .
However, every time I try to insert text longer than 4000 characters, it gives the following error:
Validation failed for one or more legal entities. See the "EntityValidationErrors" property for more details.
I tried to set the annotation for [Column(TypeName="ntext")] , but that doesn't make any difference. When I loop through the EntityValidationErrors collection, the problem is caused by BlogContent and the error says:
The string cannot be longer than 4000 characters.
How can I determine if my model has an ntext field for BlogContent ?
It seems that any data annotations are ignored; it is assumed that a string without MaxLength by default limited to 4000 characters.
Nestor
source share