实体框架和WCF问题 [英] Issue with Entity Framework and WCF

查看:74
本文介绍了实体框架和WCF问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在开发一个项目,我需要一个包含几个Entity Framework Code First类的WCF服务,它们之间有一对多的关系,我有一些方法,如添加到数据库或从数据库中获取数据,当我执行此服务并尝试在WCF客户端上使用任何此方法时,而不是预期的结果,我收到此消息:

无法调用可能的原因:服务脱机或无法访问;客户端配置与代理不匹配;现有代理无效。请参阅堆栈跟踪了解更多详细信息。您可以尝试通过启动新代理进行恢复,恢复到默认配置,或刷新服务。

如果有人知道为什么会这样,请,我请求一些帮助。谢谢和最好的问候。

Hi everyone, I'm working on a project and I need a WCF Service that contains several Entity Framework Code First classes, the have One-to-Many Relations between them, and I have some methods like add to the database or get data from the database, when I'm execute this service and try to use any of this methods on the WCF Client, instead the expected result, I'm getting this message:
"Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service."
If anyone have any idea why is this happening, please, I request some help. Thanks and Best Regards.

推荐答案

在WCF中,端点必须提供ABC - 地址,绑定,合同。



确保在配置文件中包含所有这些内容。

据我所知,如果这些属性中的任何一个缺失或不正确,就会发生这种错误。



如果您的web.config一切正常,请分享web.config文件中的服务部分。



参考:

ABCs of WCF中的EndPoint [ ^ ]

为什么无法在wcftestclient中调用WCF? [ ^ ]



希望,它有帮助:)
In WCF, an endpoint must supply the ABC - Address, Binding, Contract.

Make sure that you have all these in your config file.
As far I know, this kind of error occurs in case of any one of these property is missing or incorrect.

If everything is fine with your web.config, please share the service section from web.config file.

Reference:
ABCs of an EndPoint in WCF[^]
Why WCF cannot be invoked in wcftestclient?[^]

Hope, it helps :)


好吧,谢谢Suvendu ,问题是我确实生成了一个名为DataContext的文件,并将所有实体和Context放在该文件中,但是当我尝试添加或列出时,配置文件没有正确的从数据库文件中获取数据的配置,更具体地说,没有在我的App.config文件中配置连接字符串行,感谢建议,这非常有帮助......
well, thanks Suvendu, the problem was I did generate a file named "DataContext", and put all the entities and Context in that file, but when I'm trying to add or list, the config file didn't have the correct configuration to get the data from a database file, more specifically, didn't havethe connection string line configured in my App.config file, thanks for the advised, it was very helpful...


这篇关于实体框架和WCF问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆