EF4:使用“添加服务引用”会导致 STE(自跟踪实体)出现问题,不记得有更改吗?
我发现了一个问题,但它涉及 VS 2010 的 BETA 版本。我有兴趣知道这个问题是否已在 RTM 中修复?
基本上它指出(通过EF 4自我跟踪实体看到它没有按预期工作)
确保重复使用 自我跟踪实体模板 在您的客户端上生成实体代码。 如果您使用Add生成的代理代码 Visual Studio 中的服务参考或 其他一些工具,看起来很适合 大部分,但你会发现 这些实体实际上并没有保留 跟踪他们在客户端上的更改。
我非常习惯使用“添加服务引用”,它过去一直对我很有用,但当然我没有使用 STE(自我跟踪实体)。对于 VS 2010 RTM 和 STE 模板,此问题是否仍然存在?
如果我确实通过代码创建代理而不是添加服务,那么所有类都不会被创建,不是吗?
I found an issue but it refers to the BETA version of VS 2010. I am interested in knowing if this issue has been fixed in RTM?
Basically it states (saw it via EF 4 Self Tracking Entities does not work as expected )
Make certain to reuse the
Self-Tracking Entity template’s
generated entity code on your client.
If you use proxy code generated by Add
Service Reference in Visual Studio or
some other tool, things look right for
the most part, but you will discover
that the entities don’t actually keep
track of their changes on the client.
I am very used to using Add Service Reference, and its always worked great for me in the past but of course I wasn't using STE (Self tracking entities). Is this problem still apparent with VS 2010 RTM and the STE template?
If I do create the proxy via code instead of add service then all the classes won't be created will they?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是问题,也从来都不是问题。这绝对是预期且正确的行为。 STE 是包含数据和逻辑(逻辑跟踪更改)的类。
添加服务引用时,您的客户端代理代码是从服务的元数据生成的。元数据以 WSDL 形式公开。 WSDL 是基于 XML 的服务描述,其中还包含传输数据类型的 XSD 描述。 XSD只能描述数据格式,而不能描述类型实现的相关逻辑。默认情况下,WSDL 中描述的所有未知数据类型均在客户端生成。因此,当您通过添加服务引用生成具有所有数据类型的客户端代理时,跟踪逻辑将丢失。
要解决此问题,您必须执行两件事:
This is not an issue and it never was an issue. It is absolutly expected and correct behavior. STEs are classes which contains data and logic (the logic tracks changes).
When adding service reference your client proxy code is generated from service's metadata. Metadata are exposed in form WSDL. WSDL is XML based description of the service which also contains XSD description of transfered data types. XSD can describe only data format but not related logic implemented by the type. By default all unknown data types described in WSDL are generated on the client. So when you generate client proxy with all data types by Add service reference the tracking logic is lost.
To overcome this issue you have to do two things: