基础提供程序在open上失败
场景:急求相助:WCF 中,在SVC中使用实体查询库时报错:“基础提供程序在Open上失败了”。win8 + VS2012 + EF + localDB + IIS
急求帮助:WCF 中,在SVC中使用实体查询库时报错:“基础提供程序在Open上失败了”。win8 + VS2012 + EF + localDB + IIS
错误:WCF 中,在SVC中使用实体查询库时报错:“基础提供程序在Open上失败了”
说明:操作系统Win8;WCF发布到IIS中;数据库使用VS2012自带的localDB.
一,这是接口定义
[ServiceContract]
public interface INeed
{
[OperationContract]
[WebInvoke(
Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/uploadMdNeed",
BodyStyle = WebMessageBodyStyle.Bare
)]
String uploadMdNeed(MdNeed mdNeed);
}
二,这是接口实现
public class Need:INeed
{
public string uploadMdNeed(MdNeed mdNeed)
{
try
{
lmEntities lmEtt = new lmEntities();
NeedTb need = new NeedTb();
need.SDescribe = "描述描述";
lmEtt.NeedTb.Add(need);
lmEtt.SaveChanges();
return "使用lmEitities类实例,实现新记录的添加。结果是:成功!";
}
catch (Exception e)
{
return "操作结果是:失败了!!!" + e.Message ;
}
}
}
三,web.config内容
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetUrl="" httpGetEnabled="true" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="httpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="MyHost.Need_.Need">
<endpoint address="" binding="webHttpBinding" contract="MyHost.Need_.INeed" behaviorConfiguration="httpBehavior" />
</service>
<service name="MyHost.Thing_.Thing">
<endpoint address="" binding="webHttpBinding" contract="MyHost.Thing_.IThing" behaviorConfiguration="httpBehavior" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
<staticContent>
<mimeMap fileExtension=".apk" mimeType="applicationnd.android.package-archive" />
</staticContent>
</system.webServer>
<connectionStrings>
<add name="lmEntities"
connectionString=
"metadata=res://*/Lm.csdl|res://*/Lm.ssdl|res://*/Lm.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=(LocalDB)\v11.0;
attachdbfilename=|DataDirectory|\lm.mdf;
integrated security=True;
MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
------解决方案--------------------
实体放哪里了
metadata=res://*/Lm.csdl
------解决方案--------------------
res://*/Lm.ssdl
------解决方案--------------------
res://*/Lm.msl;
把*换成程序集名称试试。
你一下子放进解决方案的东西太多了,不好说问题在哪。
使用EF加WCF最好别直接用EF生成的实体做WCF的传值用对象,会出现好多问题。序列化方面的。
------解决方案--------------------
把项目上传到某个地方,我去下载
------解决方案--------------------
发布到IIS以后,文件lm.mdf在哪里呢?
------解决方案--------------------
看你这个函数似乎是测试用的插入而非查询吧
need.SDescribe = "描述描述"; 这个表结构就这么简单?
comment掉数据库的部分排除webservice的错误
ps: 这个中文的错误信息有点看不懂,要不发个全的ex.message看看
看楼上几位的意思这个数据库文件打不开
急求帮助:WCF 中,在SVC中使用实体查询库时报错:“基础提供程序在Open上失败了”。win8 + VS2012 + EF + localDB + IIS
错误:WCF 中,在SVC中使用实体查询库时报错:“基础提供程序在Open上失败了”
说明:操作系统Win8;WCF发布到IIS中;数据库使用VS2012自带的localDB.
一,这是接口定义
[ServiceContract]
public interface INeed
{
[OperationContract]
[WebInvoke(
Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/uploadMdNeed",
BodyStyle = WebMessageBodyStyle.Bare
)]
String uploadMdNeed(MdNeed mdNeed);
}
二,这是接口实现
public class Need:INeed
{
public string uploadMdNeed(MdNeed mdNeed)
{
try
{
lmEntities lmEtt = new lmEntities();
NeedTb need = new NeedTb();
need.SDescribe = "描述描述";
lmEtt.NeedTb.Add(need);
lmEtt.SaveChanges();
return "使用lmEitities类实例,实现新记录的添加。结果是:成功!";
}
catch (Exception e)
{
return "操作结果是:失败了!!!" + e.Message ;
}
}
}
三,web.config内容
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetUrl="" httpGetEnabled="true" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="httpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="MyHost.Need_.Need">
<endpoint address="" binding="webHttpBinding" contract="MyHost.Need_.INeed" behaviorConfiguration="httpBehavior" />
</service>
<service name="MyHost.Thing_.Thing">
<endpoint address="" binding="webHttpBinding" contract="MyHost.Thing_.IThing" behaviorConfiguration="httpBehavior" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
<staticContent>
<mimeMap fileExtension=".apk" mimeType="applicationnd.android.package-archive" />
</staticContent>
</system.webServer>
<connectionStrings>
<add name="lmEntities"
connectionString=
"metadata=res://*/Lm.csdl|res://*/Lm.ssdl|res://*/Lm.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=(LocalDB)\v11.0;
attachdbfilename=|DataDirectory|\lm.mdf;
integrated security=True;
MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
------解决方案--------------------
实体放哪里了
metadata=res://*/Lm.csdl
------解决方案--------------------
res://*/Lm.ssdl
------解决方案--------------------
res://*/Lm.msl;
把*换成程序集名称试试。
你一下子放进解决方案的东西太多了,不好说问题在哪。
使用EF加WCF最好别直接用EF生成的实体做WCF的传值用对象,会出现好多问题。序列化方面的。
------解决方案--------------------
把项目上传到某个地方,我去下载
------解决方案--------------------
发布到IIS以后,文件lm.mdf在哪里呢?
------解决方案--------------------
看你这个函数似乎是测试用的插入而非查询吧
need.SDescribe = "描述描述"; 这个表结构就这么简单?
comment掉数据库的部分排除webservice的错误
ps: 这个中文的错误信息有点看不懂,要不发个全的ex.message看看
看楼上几位的意思这个数据库文件打不开