我目前有一个使用Entity Framework6程序集引用的.Net WebAPI2项目。这是我的生产"环境。我创建了一个并行"测试"环境有一个新的测试sql数据库(生产数据库的副本)和一个WebAPITest和EFTest作为相关产品VS2013项目的副本。我能够在新的EFTest的app.config中将数据库更改为DBTest,这似乎工作正常。我在WebAPITest中更改了引用以指向新的EFTest程序集,并且它似乎正确连接。问题是,当我实际在VS2013中运行WebAPITest项目并调用WebAPITest控制器时,它仍然是最初的EF和API。我还在WebAPITest的Web.config中注释掉了它,但它仍然指向运行时的旧连接。
在WebAPITest中创建一个新的控制器是成功的,并且引用EFTest似乎都没有构建错误,但从VS运行尝试新控制器返回错误,新控制器不存在,任何预先存在的控制器仍然打击旧的EF显然。
我试图清除浏览器缓存但没有成功。 我可以更新哪些其他参考位置来解决此问题?
来自WebAPITest的App.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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="RecTaxEntities" connectionString="metadata=res://*/RecTaxEFModel1.csdl|res://*/RecTaxEFModel1.ssdl|res://*/RecTaxEFModel1.msl;provider=System.Data.SqlClient;provider connection string="data source=myserver;initial catalog=DB;user id=USER;password=PWD;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<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>
</configuration>
来自WebAPITest的Web.Config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<connectionStrings>
<!-- <add name="RecTaxEntities" connectionString="metadata=res://*/RecTaxEFModel1.csdl|res://*/RecTaxEFModel1.ssdl|res://*/RecTaxEFModel1.msl;provider=System.Data.SqlClient;provider connection string="data source=myserver;initial catalog=DB;user id=USER;password=PWD;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />-->
</connectionStrings>
<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>
</configuration>
答案 0 :(得分:0)
问题解决了。它最终成为我试图从新测试环境调用的Web API控制器名称的拼写错误。