将 ASP.NET MVC 4 应用程序(代码优先)部署到 IIS 时出现以下错误:
“从数据库获取提供程序信息时出错。这可能是由于实体框架使用了不正确的连接字符串造成的。请检查内部异常以获取详细信息并确保连接字符串正确。”
我一直在寻找答案,但没有一种情况与我的情况相符:
我有 2 个项目
- 后端(使用 Code First + WCF 服务的数据访问)
- FrontEnd MVC 4 应用程序(仅对 WCF 服务的服务引用)
在我的本地 IIS + SQL Server 2008 上它工作正常。即使我将连接字符串更改为生产数据库,一切都按预期工作。
将 BackEnd + FrontEnd 部署到 IIS 时会出现此问题。
访问 db 的唯一连接字符串位于我的后端应用程序中:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="fromMail" value="xxx@gmail.com" />
</appSettings>
<connectionStrings>
<add name="TTCWestelDbContext" connectionString="Data Source=192.168.2.14\SQLSERVER2008;Initial Catalog=TTCWestel001;Persist Security Info=True;User ID=XXX;Password=XXX" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="102400" executionTimeout="3600" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\Temp\WCFTracesTTCWestel.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
任何帮助表示赞赏!
谢谢
米克洛