c# - 实体框架 Reload() 错误 无效操作
问题描述
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()
如何使实体框架实际加载修改数据的方法的解决方案
解决方案
推荐阅读
- makefile - Yocto 配方 Busybox_1.23.2.bb 在 do_compile 失败
- javascript - 在网站上实现多语言支持的最佳方法
- rest - REST API 创建组 TFS 2018 更新 3
- java - 在 java 中使用 rsa 时发生解密错误。
- javascript - 从整个 webpack 项目中创建一个实例
- ios - 我们是否应该在 Xamarin.iOS 中调用 NSDate 的 dispose 方法
- javafx - 标签未在 javafx 中显示
- android - mapbox 在缩放级别 8 时未显示道路。*
- java - 将字符串修改应用于数组/列表
- angular - Angular 6 表单验证