使用EF的列无效

时间:2017-03-10 06:16:01

标签: entity-framework entity dbcontext

有人可以帮我解决这个问题吗?我是EF新手,我不知道这段代码发生了什么:

请在控制器

中找到以下查询
foreach (var i in tt)
{
    db.tbl_transaction.Add(i);
    db.tbl_transactionlist.Add(tm.tlist);

    var tools = (from j in db.tbl_tools_and_equips where j.itemno == i.controlno select j).First();
    //tools.location = i.destinationid;
    //tools.linemodel = i.line_model;
    //tools.usage = i.process_assign;
    tools.status = i.status;
    tools.date_maintain = i.date_maintain;
    tools.date_next_maintain = i.date_next_maintain;

}
try
{  
    /*return error: invalid columns in db.SaveChanges*/
    db.SaveChanges();

对于我的模特:

   public partial class tbl_transaction
   {
         public int transferevent { get; set; }
         public string transactionno { get; set; }
         public Nullable<int> itemno { get; set; }
         public string assetdesc { get; set; }
         public string serialno { get; set; }
         public string barcode { get; set; }
         public string sourcelocationid { get; set; }
         public string destinationid { get; set; }
         public Nullable<System.DateTime> transactiondate { get; set; }
         public Nullable<int> quantity { get; set; }
         public string unitmeasure { get; set; }
         public string remarks { get; set; }
         public string @ref { get; set; }
         public string actg_rem { get; set; }
         public string label { get; set; }
         public string station { get; set; }
         public string line_model { get; set; }
         public string process_assign { get; set; }
         public string status { get; set; }
         public string controlno { get; set; }
         public string category { get; set; }
         public Nullable<System.DateTime> date_maintain { get; set; }
         public Nullable<System.DateTime> date_repair { get; set; }
         public string defect { get; set; }
         public string repair_made { get; set; }
         public Nullable<System.DateTime> date_next_maintain { get; set; }
   }

每次执行查询时,它总是返回无效的列名。非常感谢您的帮助。

0 个答案:

没有答案