tbLog log = new tbLog(); log.Operator_name = "test"; //1会员,2服务中心,3管理员 log.Operator_Type = "管理员"; log.DateTime = DateTime.Now; log.IP = GetClientIPOrAdd.GetIP(); log.Operation = "ExecuteSqlCommand时间:" + a; db.tbLog.Add(log); tbLog log1 = log; log1.Operation = "EF时间:" + b; db.tbLog.Add(log1); db.SaveChanges();
结果log的数据被覆盖了,只有log1的数据添加进来数据库。
原文:http://www.cnblogs.com/tider1999/p/4438381.html