Insert without primary key
-
I am very new to the linq to sql getting proble when I am tryig to insert the record in a table as the table do not have any primary key. Thanks Sri...
What error are you getting? Are you aware that Linq to SQL is obsolte and Entity Framework is the successor?
Best wishes, Navaneeth
-
What error are you getting? Are you aware that Linq to SQL is obsolte and Entity Framework is the successor?
Best wishes, Navaneeth
hi Navaneeth, thanks for making reply. I am getting following error "Can't perform Create, Update or Delete operations on 'Table(TestTable)' because it has no primary key. " Code is as follows:
TestTable test = new TestTable();
test.NAME = txtNametest.Text;
test.ADDRESS = txtaddrtest.Text;
db.GetTable<TestTable>().InsertOnSubmit(test);
db.SubmitChanges();I google the problem but did not find any solution as per different forum we need to add a addition column (may identity) to set as primary key. but I don't think Its good practice to add extra column. Please suggest how should i go ahead. Thanks, Sri...
-
hi Navaneeth, thanks for making reply. I am getting following error "Can't perform Create, Update or Delete operations on 'Table(TestTable)' because it has no primary key. " Code is as follows:
TestTable test = new TestTable();
test.NAME = txtNametest.Text;
test.ADDRESS = txtaddrtest.Text;
db.GetTable<TestTable>().InsertOnSubmit(test);
db.SubmitChanges();I google the problem but did not find any solution as per different forum we need to add a addition column (may identity) to set as primary key. but I don't think Its good practice to add extra column. Please suggest how should i go ahead. Thanks, Sri...
just open the DBML-file in design mode and multi select the columns that you wand to set as primary key. for example NAME and ADDRESS. Then it will work! it is very NOT good practice to have tables i a database without a primary key!! kind regards
Andreas Johansson
IT Professional at Office IT Partner i Norrbotten Sweden
What we don't know. We learn.
What you don't know. We teach -
just open the DBML-file in design mode and multi select the columns that you wand to set as primary key. for example NAME and ADDRESS. Then it will work! it is very NOT good practice to have tables i a database without a primary key!! kind regards
Andreas Johansson
IT Professional at Office IT Partner i Norrbotten Sweden
What we don't know. We learn.
What you don't know. We teach