我正在运行Visual Studio 2012.我在我的解决方案中创建了3个项目:数据(使用Entity Framework 5),控制台UI和MVC4 UI。当我运行控制台UI时,一切正常:程序访问本地数据库。但是,当我运行MVC项目时,我收到以下错误:
Cannot attach the file 'b:\Users\path-to-project\App_Data\DataAccess.MyContext.mdf' as database 'DataAccess.MyContext'.
我将MVC项目中的Web.config与控制台项目中的App.config进行比较:
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</configSections>
和
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
在这两个地方。为什么MVC项目不会转到LocalDB?