EF & WCF error - SQL Server Compact is not intended for ASP.NET development

徘徊边缘 提交于 2019-12-07 09:35:48

问题


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?


回答1:


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.




回答2:


I know this is old post but this line of code help me to resolve the issue:

 protected void Application_Start(object sender, EventArgs e)
 {
     AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
 }

in your Global.asax




回答3:


Try this :

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigureAuth(app);
        AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
    }


}



回答4:


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



来源:https://stackoverflow.com/questions/4476058/ef-wcf-error-sql-server-compact-is-not-intended-for-asp-net-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!