SQL Server reports 'Invalid column name', but the column is present and the query works through management studio

前端 未结 12 637
生来不讨喜
生来不讨喜 2020-12-04 11:35

I\'ve hit a bit of an impasse. I have a query that is generated by some C# code. The query works fine in Microsoft SQL Server Management Studio whe

12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 12:03

    Including this answer because this was the top result for "invalid column name sql" on google and I didn't see this answer here. In my case, I was getting Invalid Column Name, Id1 because I had used the wrong id in my .HasForeignKey statement in my Entity Framework C# code. Once I changed it to match the .HasOne() object's id, the error was gone.

提交回复
热议问题