I would like to know how to map my entity that uses an Enum of type char
through the Entity Framework, using FluentApi.
I have the following Enum:
public enum Zona
{
Norte = 'N',
Sul = 'S'
}
And my Entity:
public class Local
{
public Guid RioId { get; set; }
public string Nome { get; set; }
public Zona Zona { get; set; }
}
I configured the entity as follows:
public class LocalMapping : EntityTypeConfiguration<Local>
{
public LocalMapping()
{
ToTable("Local");
HasKey(r => r.LocalId);
Property(r => r.Nome).IsRequired();
Property(r => r.Zona).IsRequired();
}
}
How do I register my Enum Zone as varchar(1)
in the database, so that when saving a Location with North Zone, the N character is saved in the Bank