我目前有一个使用实体Framework6程序集引用的.Net WebAPI2项目。这是我的“生产”环境。我用一个新的测试sql数据库(生产数据库的副本)和一个WebAPITest和EFTest创建了一个并行的“测试”环境,作为相关产品VS2013项目的副本。我能够在新的EFTest的app.config中将数据库更改为DBTest,并且似乎正常工作。我将WebAPITest中的引用更改为指向新的EFTest程序集,并且该程序似乎已正确连接。问题是,当我真的在VS2013中运行WebAPITest项目并调用WebAPITest控制器时,它仍然击中最初的EF和API。我也在WebAPITest的Web.config中注释掉了它,但它仍然指向运行时的旧连接。更改webapi中的实体框架引用
在WebAPITest中创建一个新的控制器是成功的,引用EFTest似乎都没有任何构建错误,但是从VS运行尝试新的控制器返回并且错误,新控制器不存在,并且任何先前存在的控制器仍然命中老EF显然。
我试图清除浏览器缓存没有成功。 我可以更新哪些其他参考位置来解决此问题?
App.Config中从WebAPITest
<?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>
Web.Config中从WebAPITest
<?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>
你可以发布'web.config'和你可能在这里的其他'.configs'吗? – Mrchief 2014-12-03 21:03:02
为什么你不能使用大写字母来开始问题标题?为什么问题标题中没有问号?问题标题需要形成良好,以便问题清单看起来像是一个实际问题清单。 – 2014-12-03 23:54:27