我正在使用一个简单的编码来使用实体框架在表格中添加记录,即
Transaction t = new Transaction();
t.CustomerID = 1;
t.Date = DateTime.Now;
t.Balance = 400;
t.Total = 500;
t.Paid = 100;
db.Transactions.Add(t);
db.SaveChanges();
但是在进入某些记录后,主键意外更改
请建议我一些建议谢谢。
编辑..
表格详情
CREATE TABLE [hassan].[Transaction]
(
[TransactionId] [int] IDENTITY(1,1) NOT NULL,
[Date] [datetime] NULL,
[TransactionType] [nvarchar](20) NULL,
[TransactionTypeID] [int] NULL,
[Total] [numeric](18, 0) NULL,
[Paid] [numeric](18, 0) NULL,
[Balance] [numeric](18, 0) NULL,
[Note] [nvarchar](50) NULL,
[CustomerID] [int] NULL,
[UserID] [int] NULL,
[BranchID] [int] NULL,
[Referance] [nvarchar](20) NULL,
[SupplierID] [int] NULL,
CONSTRAINT [PK_Transaction_1]
PRIMARY KEY CLUSTERED ([TransactionId] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]