myEntities dc = new myEntities();
...
//i show the table data to user
mainSearchedData = dc.Invoice.ToList();
gvMain.DataSource = mainSearchedData;
//then i change some data in the table(Somewhere else in the code) and save
//it
dc.SaveChanges(); //(the change is successfull i can se it in SSMS)
//since if i just use the gvMain.datasource set it wont load the changes
//that has been made in the tabel i want to reload
dc.Entry(dc).Reload(); <-- This is causing the error
“System.InvalidOperationException:'实体类型myEntities不是 当前背景模型的一部分。“
我对没有Reload()
方法的解决方案持开放态度如何使实体框架实际加载修改后的数据