3

I am getting this error when I perform a linq query on appusers table.

   var x = db.appusers.Where(y => y.AppUserID == 2).ToList();

enter image description here

SamuraiJack
  • 5,131
  • 15
  • 89
  • 195
  • 3
    this sounds like an inheritance problem. have you applied all migrations? – DevilSuichiro Jul 29 '18 at 11:46
  • 1
    Have you using Code First Migrations or Database/Model First? Can you provide example table structure, generated query string & stack trace to help us analyze your issue? Sounds like the column name is not exist in EDM data model. – Tetsuya Yamamoto Jul 30 '18 at 01:52
  • @DevilSuichiro that was exactly the problem. Thank you. There was a `person` class from which class A was inherited and I further inherited it into B. Not sure why that is problematic. But it solved my problem. – SamuraiJack Jul 30 '18 at 05:00
  • @TetsuyaYamamoto yes but now its solved , it had to do with inheritance. – SamuraiJack Jul 30 '18 at 05:00
  • 1
    The problem was that you've apparently recently introduced this inheritance and the database did not reflect this change. – DevilSuichiro Jul 31 '18 at 11:55
  • 1
    probably `appuser` model is created by extending another POCO model. Turns out that Entity Framework will assume that any class that inherits from a POCO class that is mapped to a table on the database requires a Discriminator column, even if the derived class will not be saved to the DB. Look at this answer for solution [here](https://stackoverflow.com/a/6586990/1349365) – Moshi Nov 29 '18 at 11:04

0 Answers0