argumentexception未被用户代码asp.net mvc处理

时间:2014-04-04 08:58:40

标签: asp.net-mvc

我遇到了Adam Freeman的pro asp.net mvc 5书。当我尝试开始调试时,我发现错误:     System.Data.dll中出现类型'System.ArgumentException'的例外但未在用户代码中处理附加信息:不支持关键字:'initialcatalog'。但我的Web.config不在书中。 屏幕:[1]:http://imgur.com/3TpOL0E

我的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=301880
  -->
<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="EFDbContext" connectionString="Data Source=(localdb)\v11.0; InitialCatalog=SportsStore; Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
     <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>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
 </configuration>

P.S。对不起,我的谷歌翻译英语。

1 个答案:

答案 0 :(得分:0)

尝试在连接字符串中添加空格,如下所示:

Initial Catalog=SportsStore;