Entity Framework issue after adding column to database table

asp.net c# entity-framework sql-server


To a table in my database, I needed to add a new NVARCHAR column. I then launched Visual Studio to update the EDMX-file for the Entity Framework after adding the column.

I attempted to update all models from the database, but all I got were "data reader is incompatible" messages. Then I ran update again, renamed the whole table in the database, updated EDMX from the database, changed the table's name back to the old name, and produced new function imports for all impacted stored procedures. But I continue to 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 done a little research and it seems that this is a typical mistake if the column name is different between the database and the framework. However, this is untrue since they share a name.

I can use [Entity] to access the column in the code. Context. I don't entirely get the data reader's complaint since [Column].

I'm out of ideas, so I'd appreciate any assistance.

8/4/2009 12:11:03 PM

Accepted Answer

The EDMX turned out to be great, however for some strange reason the designer has stopped updating Designer.cs in my project.

I had to go in and modify it by hand.

8/11/2009 7:13:14 AM

Popular Answer

The client schema or the mapping are not replaced when the model is updated, just the store schema. Open it as XML to begin with "a blank slate," your current EDMX backup. Subsequently, shut and reopen the table in the graphical error, and remove any references to it. Build. Fix any issues you see, such as any broken connections to the removed table. Re-add the table after updating the model.

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