Cómo puedo especificar la longitud máxima de columna de un campo usando el código de entity framework primero


¿Hay algún atributo que pueda usar al crear una tabla ? Lo intenté [StringLength] pero parece ser ignorado.

 public class EntityRegister
 {
     public int Id { get; set; }
     [StringLength(450)]
     public string Name { get; set; }
 }
Author: John Woo, 2012-12-23

1 answers

Alternativamente, puede hacerlo manualmente en Fluent API

Use HasMaxLength(450)

O si quieres Data Annotation, usa MaxLength y MinLength atributos

public class EntityRegister
{
    public int Id { get; set; }
    [MaxLength(450)]
    public string Name { get; set; }
}
 54
Author: John Woo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-23 03:52:56