Invalid column name '*_ID'


Question: Entity Framework Code First Error "Invalid Column 'ColumnName". I am confused on this error, I don't know where the error is coming from. I have spent hours trying to understand why the error occurs. I have checked everywhere to see if I have any Column defined but can't find any. 



Login to See the Rest of the Answer

Answer:
The answer is simple, well, it depends with your scenerial but am betting my money on the case that you have included a list of entities in one of your POCO (Modal Class) that you don't have navigation defined.

Navigation in Entity Framework 7 is another big topic, but I would advise you to check the class that the error is thrown in and see if you have Mapped a list of entities that has no connection with the parent Entity you are trying to retrieve from the datatabase.

See Example below:

namespace NameOfTheCodeGroup { 
    public partial class ParentEntity
    {
        [Key]
        public int Id { get; set; }
        public string SomeProperty { get; set; }
     //  [NotMapped]
    //This is where your problem is, there is no ParentEntityId in class OtherEntity that would create Navigation (connection between two)
        public List<OtherEntity> listOfOtherEntity { get; set; } = new List<OtherEntity>(); //Code throws an error here
    }
}

Leave a comment below if this solved your error.






For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email AddressContact: [email protected]