如何在另一个程序集中使用 ADO.NET 实体模型设置 WCF 数据服务?
我有一个 ASP.NET 4.0 网站,该网站有一个连接到 WCF 数据服务的实体数据模型。当服务和模型位于同一程序集中时,一切正常。不幸的是,当我将模型移动到另一个“共享”程序集(并更改命名空间)时,该服务会编译,但在浏览器中启动时会抛出 500 错误。我希望将模型放在公共程序集中(让我们称之为 RiaTest.Shared)的原因是我希望在客户端和服务之间共享公共验证代码(通过在“添加”的“高级”选项卡中选中“重用引用程序集中的类型”)服务参考对话框)。
无论如何,我花了几个小时对此没有任何效果,所以在这方面的任何帮助将不胜感激......
I have an ASP.NET 4.0 website that has an Entity Data Model hooked up to WCF Data Service. When the Service and Model are in the same assembly everything works. Unfortunately, when I move the Model to another "shared" assembly (and change the namespace) the service compiles but throws a 500 error when launched in a browser. The reason I want to have the Model in a common assembly (lets call it RiaTest.Shared) is that I want share common validation code between the client and service (by checking "Reuse types in referenced assemblies" in the Advanced tab of the Add Service Reference dialog).
Anyway, I've spent a couple of hours on this to no avail so any help in the regard would be appreciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您将 EF 数据模型移动到其自己的程序集中时,您需要确保 WCF 数据服务所在的 web.config 中仍然具有 EDM 连接。您是否可以删除该连接字符串?
在从 Web 应用程序的单独程序集中引用 EDM 模型后,我遇到了完全相同的错误。当我将 EDM 连接字符串从模型程序集复制到 WCF 数据服务所在的 Web 应用程序的 web.config 后,一切都进展顺利!
When you move the EF data model into its own assembly, you need to make sure to still have the EDM connection in your web.config where your WCF Data Service lives. Did you possibly remove that connection string??
I got the very same error after I referenced an EDM model in a separate assembly from a web application. Once I copied the EDM connection string from the model assembly to the web.config for the web application where my WCF Data Service lives, everything worked out just fine!