EF & WCF error - SQL Server Compact is not intended for ASP.NET development
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开发者_如何学C." 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?
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.
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
Try this :
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
}
}
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
精彩评论