Visual Studio不会创建localDB

时间:2012-11-22 08:50:50

标签: entity-framework-4 visual-studio-2012 localdb

我正在运行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?

0 个答案:

没有答案