Entity Framework issue after adding column to database table

asp.net c# entity-framework sql-server


I needed to add a new NVARCHAR column to a table in my DB. So I added the column, and then fired up Visual Studio to update the EDMX-file for the Entity Framework.

I ran update model from database on everything, which only resulted in "data reader is incompatible"-errors. So I renamed the whole table in the DB, updated EDMX from database, renamed the table back to the original name, ran update again, and then created new function imports for all affected stored procedures. But I still get the same error:

The data reader is incompatible with the specified '[Model].[Entity]'. A member of the type, '[Column]', does not have a corresponding column in the data reader with the same name.

I've looked around a bit, and this seems to be a common error if the column name is different in the database and framework. This is however not the case, they have the same name.

I can access the column in the code via [Entity].Context.[Column], so I don't quite see what the data reader is complaining about.

I've run out of ideas, so any help welcome.

8/4/2009 12:11:03 PM

Accepted Answer

Turns out the EDMX was fine, but the designer has, for some odd reason, stopped update Designer.cs in my project.

Had to go in and manually edit it.

8/11/2009 7:13:14 AM

Popular Answer

Updating the model replaces the store schema, but not the client schema or the mapping. To start with "a clean slate", back up your current EDMX, then open it as XML. Remove all references to the table, then close and open in the graphical error. Build. If you have any errors (perhaps broken links to the deleted table), fix them. Then update model to re-add the table.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow