C#C
C#3y ago
Tvde1

Not mapping an EF Core DB-First enum property

I have scaffolded my Db Context. My entity has a
[Column("status")]
public string _status { get; set; }

I am making a partial class which is:
public partial class Host
{
    [NotMapped]
    public HostStatus Status
    {
        get => Enum.Parse<HostStatus>(this._status);
        set => this._status = value.ToString().ToLower();
    }
}

Yet, when I do _context.Hosts.ToList(), it does attempt to select a column named "Status". How do I prevent this? The NotMapped attribute does not seem to be working.
Was this page helpful?