Search code examples
c#entity-frameworkef-code-firstentity-framework-core

What happened to HasColumnName for EF Core?


So I am trying to map an internal property to my database and according to this article online this is how you are supposed to do it. The other resources that I found also tell me to do the same thing. For whatever reason the method doesn't exist and I can't find online what they renamed it too or if they just removed the method.

Here is my code:

public class Criteria : DbEntity
{

    internal string _Condition { get; set; }

    [NotMapped]
    public Condition Condition 
    {
        get
        {
            return string.IsNullOrEmpty(_Condition) ? null : JsonConvert.DeserializeObject<Condition>(_Condition);
        }
        set
        {
            _Condition = JsonConvert.SerializeObject(value);
        }
    }

}

protected override void OnModelCreating(ModelBuilder builder)
{
    builder.Entity<Criteria>().Property(b => b._Condition);//.HasColumnName("Condition"); <-- this doesn't exist...
}

Solution

  • Had to install Microsoft.EntityFrameworkCore.Relational to fix the issue.

    Edit: Credit goes to Ivan Stoev for finding this out