我正在尝试在表中插入值。我这样做如下:
JobTable jobTable = new JobTable();
int result = -1;
JobEntities context = new JobEntities();
try
{
jobTable.JobDate = DateTime.Now;
jobTable.JobProcess = processName;
context.JobTable.Attach(jobTable);
context.JobTable.Add(jobTable);
result = context.SaveChanges();
Console.WriteLine("Result => " + result.ToString());
}
catch (Exception)
{
throw;
}
return jobTable.JobId;
我每次都会得到一个新的 JobId,但是当我检查我的数据库时,表保持为空。我错过了什么?