Entity Framework: Invalid column name ‘OrganizationStructure_ID’

That is because you didn’t pair your FK property with a navigation property. I expect the ParentID should point to parent OrganizationStructure and ChildrenItems should point to children OranizationStructures.

If your model doesn’t contain Parent navigation property to parent OrganizationStructure you must use fluent-API to tell EF that ParentID is FK:

modelBuilder.Entity<OrganizationStructure>()
            .HasMany(o => o.ChildrenItems)
            .WithOptional()
            .HasForeignKey(c => c.ParentID);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)