I try to run ELMAH with my ASP.NET MVC 2 project but have some problem to get it to work with my SQL Server 2008 R2 database.
This is what I have done.
Run the dbscript in my database, accidentally I ran it twice but it seems to not matter in this case.
Add the following section to my web.config
(under configSection
):
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="MyEntities" />
</elmah>
This is how 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="Data Source=000.000.000.000;Initial Catalog=MyDatabase;Persist Security Info=True;User ID=[username];Password=[password];MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
When visiting the admin/elmah/ page I get the following exception :
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
What am I doing wrong?
Entity framework connection string is different from sqlclient connection string and they are not compatible. You have to use sqlclient connection string to work with elmah. Look at this site for valid connection strings: http://connectionstrings.com/sql-server-2008
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With