Frage

Is there an attribute I can use when creating a table ? I tried [StringLength] but it seems to be ignored.

 public class EntityRegister
 {
     public int Id { get; set; }
     [StringLength(450)]
     public string Name { get; set; }
 }
War es hilfreich?

Lösung

alternatively, you can manually do it on Fluent API

use HasMaxLength(450)

  • Configuring Properties and Types with the Fluent API

or if you want Data Annotation, use MaxLength and MinLength attributes

public class EntityRegister
{
    public int Id { get; set; }
    [MaxLength(450)]
    public string Name { get; set; }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top