且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架连接异常克隆后

更新时间:2023-12-05 23:12:16

我会质疑你的方法。 需要几秒钟复制整个实体图应敲响了一些警钟。这听起来像你存储的大部分数据在内存中。因为你可以并不意味着你应该。我会尝试重新设计使用延迟加载。

I would question your approach. "takes several seconds to copy the whole entity graph" should be ringing some alarm bells. It sounds like you are storing the most of your data in memory. Just because you can doesn't mean you should. I would try re-architect you use deferred loading.

不过的是,您使用的分离实体(POCO的方法)虽这么说?这可能会在这方面提供帮助,因为他们对上下文脱钩,这可能会给你的灵活性带来的实体进出上下文的。

However that being said, are you using decoupled entities (The POCO approach)? This might help in this regard since they decouple from the context more and this might give you the flexibility to bring entities in and out of the context.