So I have a table in the database, with a column that is simply an nvarchar(800).
When I try to do:
try
{
UserTable = (from x in entities.userTab
Is there a PK on the table at all? If not, EF uses all of the fields/columns as part of the "key information."
Follow these simple steps
Step 1: Check whether your table is having primary key column in database or not. If it does not have any primary key then add a primary key. Because if we don't add a primary key to table than entity framework creates its own key collection and add all columns in it.
Step 2: Open your .edmx file to see table object mapping. You will be able to see each column of table is having icon like primary key. So Write click on your page and update .edmx from database.
Step 3: If you still see same primary key icons on all columns than click on column name you want to update one by one and go to property window and Set Entity Key property to false.
View the data model by double clicking on the edmx file under the Models folder.
Make sure the keys are properly mapped. If you right click on a column you can toggle the Entity Key property. Once the column in question is not marked as entity key you should be able to update the value.
The problem here is that Entity Framework cannot make changes to the primary key of the particular table. Now if you have not specified a primary key for your Table, entity framework will consider everything as the primary key, and thus you won't be able to make changes to the table. What you need to do is, define a primary key in the table, delete the table from your model from the Model Browser, and then re-add the table in the model. This shall surely fix it. Happy coding. Cheers!