The property 'text' is part of the object's key information and cannot be modified

前端 未结 4 830
青春惊慌失措
青春惊慌失措 2021-01-12 05:58

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         


        
4条回答
  •  孤街浪徒
    2021-01-12 06:19

    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.

提交回复
热议问题