]> EntityFramework - The column name is not valid. 🌐:aligrant.com

EntityFramework - The column name is not valid.

Alastair Grant | Thursday 3 December 2015
"The column name is not valid. [ Node name (if any) = Extent1,Column name = Discriminator ]"

This appeared, seemingly randomly the other day. Entity Framework 6 running against SQL Server Compact Edition.

I rolled back my database and model code to try and clear the error but it persisted. The give away to fix this is the column name, Discriminator - this is a special (by convention) column used by EF to allow you to use inheritance with your POCO classes. If you wanted to use one database table to back a base class and it's children then a discriminator is used for EF to identify which class a data row corresponds to.

The confusing thing for me here was that this is existing code that has been working for a long time and I wasn't referencing any child classes. As it turned out, whilst I wasn't referencing any child classes, I had defined some elsewhere for a future idea I was working on. And even though this class wasn't being used, it was enough to cause the Entity Framework to have a wobbly.

Removing the class immediately fixed the problem.

Breaking from the voyeuristic norms of the Internet, any comments can be made in private by contacting me.