0

I wanna ask about "invalid column name 'discriminator'".

I'm trying to access data using, for example, db.[Table-Name].ToList(). I generated my model using Entity Framework code first from database and when I try to access the table data it gives me the mentioned error.

BDL
  • 21,052
  • 22
  • 49
  • 55
  • Could you please [edit] your question to include a [mcve]? You should include the code you're trying to run (using [formatted text](https://stackoverflow.com/editing-help), no pictures of code please!), and if possible the generated EF model and database schema. – Hoppeduppeanut Aug 16 '18 at 05:54
  • Possible duplicate of [EF Code First "Invalid column name 'Discriminator'" but no inheritance](https://stackoverflow.com/questions/6553935/ef-code-first-invalid-column-name-discriminator-but-no-inheritance) – Hoppeduppeanut Aug 16 '18 at 06:00

1 Answers1

0

The general reason:

The Database field and entity class field inconsistencies caused if you have an entity class mapped to entity framework, and you add another class to your project that inherits from that class, it may break Entity Framework. You could mark the child class as [NotMapped] so that EF doesn't try to include it in the map. This also means you won't be able to use it in EF queries.

You might get help from the following post. EF Code First "Invalid column name 'Discriminator'" but no inheritance