Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未找到通过WCF与实体框架的命名连接?_C#_Entity Framework_Wcf_N Tier Architecture - Fatal编程技术网

C# 未找到通过WCF与实体框架的命名连接?

C# 未找到通过WCF与实体框架的命名连接?,c#,entity-framework,wcf,n-tier-architecture,C#,Entity Framework,Wcf,N Tier Architecture,我是一个新尝试通过WCF和实体框架构建N层应用程序的人。我对所有这些都不熟悉,所以如果我听起来无知,请道歉 我正在尝试进行测试,当我试图通过WCF服务查询数据库时,出现了这个错误 指定的命名连接在配置中找不到、不打算与EntityClient提供程序一起使用,或者无效 我只是将粘贴的连接字符串从Entity Framework项目复制到我的WCF主机web.config,所以我不确定出了什么问题 有什么想法吗 web.config <?xml version="1.0"?> <

我是一个新尝试通过WCF和实体框架构建N层应用程序的人。我对所有这些都不熟悉,所以如果我听起来无知,请道歉

我正在尝试进行测试,当我试图通过WCF服务查询数据库时,出现了这个错误

指定的命名连接在配置中找不到、不打算与EntityClient提供程序一起使用,或者无效

我只是将粘贴的连接字符串从Entity Framework项目复制到我的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=&quot;data source=****;initial catalog=AerosPACE_CCADE;persist security info=True;user id=****;password=****;MultipleActiveResultSets=True;App=EntityFramework&quot;" 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>

您还需要entityFramework部分

<configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
</entityFramework>