locked
Invalid column name exist message for non existing column in Entity frame work RRS feed

  • Question

  • User-1355965324 posted

    When I appy the following Linq Expression below , the error is coming Invalid column name 'DepotModelDepotID'.  In model and in Sqlserve table not using such column any where. We had a column before DepotId and we removed the column from model  as well as from table . So there s not physically exist that column anywhere  in my project and database. Still showing the error message when I apply Linq expression in goemployee model. How can I fix this issue. Please help

    var objIndexRecords = goContext.goEmployee.FirstOrDefault(x => x.EmployeeID == salary.EmployeeID);

    Friday, December 11, 2020 2:57 PM

All replies

  • User475983607 posted

    This looks like a continuation from this thread.  I guess you finally ran the code through the debugger.

    https://forums.asp.net/t/2172889.aspx?DBcontext+SaveChanges+keeps+returning+0+when+updating+the+Employee+Salary

    When I appy the following Linq Expression below , the error is coming Invalid column name 'DepotModelDepotID'.  In model and in Sqlserve table not using such column any where. We had a column before DepotId and we removed the column from model  as well as from table . So there s not physically exist that column anywhere  in my project and database. Still showing the error message when I apply Linq expression in goemployee model. How can I fix this issue. Please help

    var objIndexRecords = goContext.goEmployee.FirstOrDefault(x => x.EmployeeID == salary.EmployeeID);

    My best guess is you did not follow openly published Code First standards.  You removed the column and model property manually rather than invoking a migration.  Doing so breaks Code First.   It is difficult to provide a solution without understanding the steps performed to get to this error.  

    Friday, December 11, 2020 3:13 PM
  • User-1355965324 posted

    mgebhred

    The project was earlier in Ado.net . I changed into Entity Frame Work. So it is not possible to run migration process. I know  that is the problem. Is there any way can we locate the error. 

    Friday, December 11, 2020 4:07 PM
  • User475983607 posted

    The project was earlier in Ado.net . I changed into Entity Frame Work. So it is not possible to run migration process. I know  that is the problem. Is there any way can we locate the error. 

    I'm confused by your response.  Can you clarify?  This is an ASP.NET Core support forum and EF Core only supports Code First.  Clearly you are using LINQ to Entities.  Did you post in the wrong forum?

    Perhaps you ran a command line to scaffold the models without understanding that you create a Code First Models?  

    Friday, December 11, 2020 4:22 PM