foreach (var item in orderdetails) { var billdetails = new BillDetail(){BillCode = billoflading.BillCode,StockId = item.StockId,PCS = item.PCS,CreateDate = DateTime.Now}; _db.BillDetails.Add(billdetails); } _db.SaveChanges();