1
I am mapping a class (System) in EF Core, but I would like to create constants for the size of the characters, because when I go to map the class, I would just change the value of the constant and it would change everywhere in the system. Only I don’t know how to use the constant in my Dbcontext.cs. Someone could help me?
public class Sistema
{
public const int TamanhoMaxDescricao = 45;
public int SistemaId { get; set; }
public string Descricao { get; set; }
public string Versao { get; set; }
public virtual ICollection<BackupAgendamento> BackupsAgendamentos { get; set; }
public virtual ICollection<Tabela> Tabela { get; set; }
public virtual ICollection<SistemaBackup> SistemaBackups { get; set; }
}
modelBuilder.Entity<Sistema>()
.Property(s => s.Descricao)
.HasColumnName("Descricao")
.HasColumnType("Varchar(50)") //Usar constante aqui para informar o tanho
.HasMaxLength(50)
.IsRequired();
I’ve never used it, but you’re having some trouble?
– Maniero
I cannot call the count... It does not appear... Ex: . Hasmaxlength(System.Tam
– Master JR
It doesn’t show up where? It’s not to trim anything.
– Maniero