我想更新我的数据库表中的三个字段/列。其中之一是主键“id”,我使用 Visual Studio 的设置列属性使其自动递增:
Identity Specification: Yes
(Is Identity) : Yes
Identity Seed : 1
Identity Increment : 1
一切正常,但在检查了 2 次后,我清空了表的内容,以便可以重新填充列。但是第一行自动增量列的值是 3。我删除了该行并再次尝试,但在行更新后它变成了 4。我不知道发生了什么。我想我的 linq 代码与它无关,因为它只是插入。
linq背后的代码:
//DLCountryies - .dbml filename
// tblcountry - tablename
// CountryName and CountryCode are Column names
//txtCountryName - textbox
using (DLCountryiesDataContext countries = new DLCountryiesDataContext())
{
tblcountry country = new tblcountry
{
CountryName = txtCountryName.Text.Trim(),
CountryCode = txtCountryCode.Text.Trim()
};
countries.tblcountries.InsertOnSubmit(country);
countries.SubmitChanges();
}