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

我在做什麼錯?

回答