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 map the class, I would just change the value of the constant and it would change in all places in the system. I just do not know how to use the constant in my DbContext.cs. Could someone 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();