ELMAH and SQL Server 2008 R2?

I am trying to start ELMAH with my ASP.NET MVC 2 project, but have some problems to get it working with my SQL Server 2008 R2 database.

This is what I did.

  • Run dbscript in my database, I accidentally ran it twice, but in this case it does not matter.

  • Add the following section to my web.config (under configSection ):

     <elmah> <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="MyEntities" /> </elmah> 
  • Here's what my Entity Framework connection string looks like:

     <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" /> 

When visiting admin / elmah / page, the following exception occurs:

Keyword not supported: "metadata". Description: An unhandled exception occurred during the execution of the current web request. please view the stack trace for more information about the error and it came from the code.

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

Source Error:

An unhandled exception was thrown during the execution of the current web request. Information about 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 Syntax, 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

What am I doing wrong?

+6
source share
1 answer

The connection string of the Entity structure is different from the sqlclient connection string, and they are incompatible. You must use the sqlclient connection string to work with elmah. Take a look at this site for valid connection strings: http://connectionstrings.com/sql-server-2008

+8
source

Source: https://habr.com/ru/post/906021/


All Articles