I've spent decent amount of time on this problem and still can't figure out why EF team makes the life so hard using Code First.
So here is some sample:
My POCO:
The way I want the thing to look like:
public class Post
{
public int Id {get; set;}
public string Text {get; set;}
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Post>()
.Property(p => p.Text)
.HasColumnType("nvarchar(max)");
}
The only thing that works:
public class Post
{
public int Id {get; set;}
[StringLength(4000)]
public string Text {get; set;}
}
The problem is that when in first case I try to insert anything it gives me: Validation failed for one or more entities
and the second case doesn't fit my business model.
Am I the only one with this problem? How do I deal with this thing?