Getting the error “cannot add an entity that already exists.” while inserting a table's value in to DB without procedure

前端 未结 5 1755
谎友^
谎友^ 2021-01-21 05:15

I am inserting a list of records to the DB table with Linq to sql like this:

//my DataContext Class
 using (VTMMedicalDBDataContext objVTMMedicalDBDataContext =          


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-21 06:05

    You have to update table to have that column with identity value (autoincrement).

    Then update your DBML model-> Delete the table from DBML designer, refresh your table at server explorer and drag and drop the table object again. Generate the project and it should work nice.

提交回复
热议问题