EF& WCF 错误 - SQL Server Compact 不适用于 ASP.NET 开发
您好,我有一个简单的 wpf 应用程序设置来使用在另一个项目中运行的测试 wcf 服务。该服务使用实体框架从附加到 wcf 服务项目的 SQL Compact 3.5 sdf 中检索几行。
我收到“SQL Server Compact 不适用于 ASP.NET 开发”。当我尝试运行其中一个服务时,服务项目中的对象上下文类的第一行出现错误。
据说可以使用“AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);”来抑制此错误在 global.asmx 文件中。然而这不是一个asp.net项目,所以没有global.asmx。
我应该把这条线放在哪里?或者SQL CE 3.5不是为EF和WCF设计的?
Hi I have a simple wpf app setup to consume my test wcf service running in another project. The service retrieves a few rows from a sql compact 3.5 sdf attached to the wcf service project using Entity Framework.
Im getting the "SQL Server Compact is not intended for ASP.NET development." error on the 1st line of the of my object context class in the service project as soon as I try and run one of the services.
This error supposedly can be suppressed with "AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);" in the global.asmx file. However this is not an asp.net project so no global.asmx.
Where should I put this line? or is SQL CE 3.5 not designed for EF and WCF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该将该行作为第一个执行代码。如果是普通的console/winform/wpf应用程序,只需将其放在Porgram.cs文件中main()函数的第一行即可。
更好的解决方案可能是升级到 v4。 0,根本不会生成此错误。
You should put the line as the first execution code. If it is a normal console/winform/wpf application, just put it in the first line of main() function in Porgram.cs file.
A better solution might be upgrade to v4.0, which does not generate this error at all.
我知道这是旧帖子,但这行代码帮助我解决了问题:
在您的 Global.asax 中
I know this is old post but this line of code help me to resolve the issue:
in your Global.asax
试试这个:
Try this :
ASP.NET 下托管的应用程序不支持 SQL Server Compact 3.5,请改用 4.0 版。它不需要设置此属性,并且经过 ASP.NET 测试和支持
SQL Server Compact 3.5 is not supported with applications hosted under ASP.NET, use version 4.0 instead. It does not require this property to be set, and is tested and supported with ASP.NET