Entity Framework Data Annotations Set StringLength VarChar

Use ColumnAttribute to give the datatype

[Column(TypeName = "VARCHAR")]
[StringLength(250)]
public string Comment { get; set; }

Or use fluent API

modelBuilder.Entity<MyEntity>()
  .Property(e => e.Comment).HasColumnType("VARCHAR").HasMaxLength(250);

Leave a Comment