【发布时间】:2014-10-15 12:51:37
【问题描述】:
我是新尝试通过 WCF 和实体框架构建 N 层应用程序。我对所有这些都是新手,如果我听起来很无知,请道歉。
我正在尝试测试,当我尝试通过 WCF 服务查询数据库时出现此错误。
在配置中找不到指定的命名连接,不打算与 EntityClient 提供程序一起使用,或者无效。
我只是将我的连接字符串从实体框架项目复制粘贴到我的 WCF 主机 web.config,所以我不确定出了什么问题。
有什么想法吗?
web.config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="AerosPACE_CCADEEntities" connectionString="metadata=res://*/AerospaceModel.csdl|res://*/AerospaceModel.ssdl|res://*/AerospaceModel.msl;provider=System.Data.SqlClient;provider connection string="data source=****;initial catalog=AerosPACE_CCADE;persist security info=True;user id=****;password=****;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="AerospaceCCADE.Server.Domain.Service.AerosPACE_CCADEDataService">
<endpoint address="" binding="wsHttpBinding" contract="AerospaceCCADE.Common.Domain.Service.Contracts.IAerosPACE_CCADEDataService" bindingConfiguration="WS-AT" />
<endpoint address="basic" binding="basicHttpBinding" contract="AerospaceCCADE.Common.Domain.Service.Contracts.IAerosPACE_CCADEDataService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="WS-AT" transactionFlow="true" />
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
和客户端App.config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
</connectionStrings>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_DataService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="true" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="67108864"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:5482/AerosPACE_CCADEDataService.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_DataService"
contract="AerospaceCCADE.Common.Domain.Service.Contracts.IAerosPACE_CCADEDataService"
name="AerosPACE_CCADEDataService"/>
</client>
<behaviors>
<endpointBehaviors>
<behavior>
<clientCredentials>
<!--allow server to use client credentials for impersonation-->
<windows allowedImpersonationLevel="Impersonation" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
【问题讨论】:
标签: c# entity-framework wcf n-tier-architecture