Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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... } 
like image 939
G3tinmybelly Avatar asked Aug 06 '17 21:08

G3tinmybelly


People also ask

Can Core 3.1 Use EF Core 5?

EF Core 5.0 requires a . NET Standard 2.1 platform. This means EF Core 5.0 will run on . NET Core 3.1 or .

What is the latest version of EF core?

The most recent Entity Framework Core 6.0 (EF Core 6) was released on 10 November 2021.

What is IEntityTypeConfiguration?

IEntityTypeConfiguration<TEntity> InterfaceAllows configuration for an entity type to be factored into a separate class, rather than in-line in OnModelCreating(ModelBuilder).


1 Answers

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

Edit: Credit goes to Ivan Stoev for finding this out

like image 88
G3tinmybelly Avatar answered Sep 23 '22 08:09

G3tinmybelly