Entity framework creating a non existent column in the query
c#, ef-code-first, entity-framework, oracle
Solution
Bpid_id is created by EF because it can't automatically determine the relationship. Try adding the annotation:
[ForeignKey("ID")]
public virtual Bpid Bpid { get; set; } //new
Problem
This has been puzzling me for quite some time but I keep getting an invalid identifier error when my entity framework tries to execute an oracle query. The classes in question are the following: ``` public class Projectship : ModelTrackingBase { [Column("PROJECTID")] public long ProjectId { get; set; } [Column("VISITID")] public long VisitId { get; set; } public virtual Bpid Bpid { get; set; } //new public virtual Visit Visit { get; set; } } ``` and ``` public class Bpid : EntityIdBase { [Column("BUDPRJID")] [MaxLength(38)] public string BPId { get; set; } [Column("DESCRIPTION")] [MaxLength(255)] public string Description { get; set; } [Column("CSTOBJ")] [MaxLength(255)] public string Custobj { get; set; } [Column("PVID")] [MaxLength(255)] public string Pvid { get; set; } public virtual ICollection<Projectship> Projectships { get; set; } public IEnumerable<Visit> Visits { get { return Projectships.Select(p => p.Visit); } } [NotMapped] public string DisplayName { get { return string.Format("{0}: {1}", BPId , Description); } } } ``` Now the EntityIdBase has the following: ``` public class EntityIdBase : EntityBase { [Column("ID")] public long Id { get; set; } } ``` It tries to keep on looking for a column Bpid_Id in the query. Does someone have any idea?