6

我尝试运行我的ASP.NET MVC 2项目中的ELMAH,但遇到一些问题需要使用我的SQL Server 2008 R2数据库。ELMAH和SQL Server 2008 R2?

这就是我所做的。

  • 在我的数据库中运行dbscript,不小心我跑了两次,但在这种情况下似乎并不重要。

  • 将以下部分添加到我的web.config(下configSection):

    <elmah> 
        <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="MyEntities" /> 
    </elmah> 
    
  • 这是我的实体框架的连接字符串的样子:

    <add name="MyEntities" 
        connectionString="metadata=res://*/Models.Model.MyEntities.csdl|res://*/Models.Model.MyEntities.ssdl|res://*/Models.Model.MyEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=000.000.000.000;Initial Catalog=MyDatabase;Persist Security Info=True;User ID=[username];Password=[password];MultipleActiveResultSets=True&quot;" 
        providerName="System.Data.EntityClient" /> 
    

当访问管理员/ elmah/page我收到以下例外情况:

Keyword not supported: 'metadata'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Keyword not supported: 'metadata'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: Keyword not supported: 'metadata'.]
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +5110868
System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +98
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +64
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +24
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +150
System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) +59

我在做什么错?

回答