vb.net - Visual studio - IDENTITY_INSERT is set to OFF -


i'm trying add records local database using visual studio 2015 , linq sql commands, error identity_insert set off.

i'm not inserting value primary key , identity specification set true. generated script file:

create table [dbo].[monte_carlo] (     [pk]        int             identity (1, 1) not null,     [id]        int             not null,     [book_comp] nchar (10)      not null,     [greek]     nchar (10)      not null,     [dp1]       decimal (18, 6) not null,     [dp2]       decimal (18, 6) not null,     [dp3]       decimal (18, 6) not null,     [dp4]       decimal (18, 6) not null,     [dp5]       decimal (18, 6) not null,     [dp6]       decimal (18, 6) not null,     [dp7]       decimal (18, 6) not null,     [dp8]       decimal (18, 6) not null,     [dp9]       decimal (18, 6) not null,     [dp10]      decimal (18, 6) not null,     [dp11]      decimal (18, 6) not null,     [dp12]      decimal (18, 6) not null,     [dp13]      decimal (18, 6) not null,     [dp14]      decimal (18, 6) not null,     [dp15]      decimal (18, 6) not null,     [dp16]      decimal (18, 6) not null,     [dp17]      decimal (18, 6) not null,     [dp18]      decimal (18, 6) not null,     [dp19]      decimal (18, 6) not null,     [dp20]      decimal (18, 6) not null,     [dp21]      decimal (18, 6) not null,     constraint [pk_monte_carlo] primary key clustered ([pk] asc) ); 

this code update datatable. i'm passing dictionary (dct)to function handles updating.

dim mcquery = updtmc in data.monte_carlos        'id exists update data                           updtmc.id = cstr(dct("id")) , updtmc.book_comp = cstr(dct("book_comp")) , updtmc.greek = cstr(dct("greek"))                           select updtmc             each updtmc monte_carlo in mcquery                  updtmc.id = dct("id")                 updtmc.book_comp = dct("book_comp")                 updtmc.greek = dct("greek")                 updtmc.dp1 = dct("dp1")                 updtmc.dp2 = dct("dp2")                 updtmc.dp3 = dct("dp3")                 updtmc.dp4 = dct("dp4")                 updtmc.dp5 = dct("dp5")                 updtmc.dp6 = dct("dp6")                 updtmc.dp7 = dct("dp7")                 updtmc.dp8 = dct("dp8")                 updtmc.dp9 = dct("dp9")                 updtmc.dp10 = dct("dp10")                 updtmc.dp11 = dct("dp11")                 updtmc.dp12 = dct("dp12")                 updtmc.dp13 = dct("dp13")                 updtmc.dp14 = dct("dp14")                 updtmc.dp15 = dct("dp15")                 updtmc.dp16 = dct("dp16")                 updtmc.dp17 = dct("dp17")                 updtmc.dp18 = dct("dp18")                 updtmc.dp19 = dct("dp19")                 updtmc.dp20 = dct("dp20")                 updtmc.dp21 = dct("dp21")             next         end if          data.submitchanges() 

monte_carlo settings

linq sql files monte_carlo:

<global.system.data.linq.mapping.tableattribute(name:="dbo.monte_carlo")>  _ partial public class monte_carlo     implements system.componentmodel.inotifypropertychanging, system.componentmodel.inotifypropertychanged      private shared emptychangingeventargs propertychangingeventargs = new propertychangingeventargs(string.empty)      private _pk integer      private _id integer      private _book_comp string      private _greek string      private _dp1 decimal      private _dp2 decimal      private _dp3 decimal      private _dp4 decimal      private _dp5 decimal      private _dp6 decimal      private _dp7 decimal      private _dp8 decimal      private _dp9 decimal      private _dp10 decimal      private _dp11 decimal      private _dp12 decimal      private _dp13 decimal      private _dp14 decimal      private _dp15 decimal      private _dp16 decimal      private _dp17 decimal      private _dp18 decimal      private _dp19 decimal      private _dp20 decimal      private _dp21 decimal      private _book entityref(of book) 

based on naming conventions in entity framework columns name id considered id, having problem. try change name of field id.


Comments