Is there a way to map a string column to an enum in an Entity Model?
I have done this in Hibernate, but can\'t figure it out in EMF.
You can do either:
Decorate the Enum property in your class as a text column
[Column(TypeName = "nvarchar(50)")]
public FileTypes FileType { get; set; }
OR
in your DatabaseContext
class, override the OnModelCreating
and add:
modelBuilder
.Entity()
.Property(e => e.FileType)
.HasConversion(new EnumToStringConverter());