As the title implies:
how is it possible to tell Entity Framework 4.1 in code first approach, that i do want some properties (in particular of type string) to have a le
In EF4.1 RTW default length is nvarchar(max) for SQL Server and nvarchar(4000) for SQL CE. To change the length use either StringLength
or MaxLength
annotations or fluent mapping HasMaxLength
:
[StringLength(256)]
public string Title { get; set; }
Or
[MaxLength(256)]
public string Title { get; set; }
Or
modelBuilder.Entity()
.Property(p => p.Title)
.HasMaxLength(256);