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 have manually set the field BlogContent
to be of ntext
type (16 bytes) in the SQL CE4
database.
However, every time I try to insert text longer than 4000 characters, it gives the following error:
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details
I have tried setting the annotation for [Column(TypeName="ntext")]
, but this makes no difference. When I loop trough the EntityValidationErrors
collection, the problem is caused by BlogContent
and the error says:
String cannot be longer than 4000 characters
How can I define my model to have an ntext
field for BlogContent
?
It seems that any data annotations are ignored; it is assuming that a string with no MaxLength
is limited to 4000 characters by default.