This is how I configured elmah to write to MySQL. In Visual Studio ...
- Install Elmah Nuget Package
- Install Elmah.MySQL Nuget Package
These two settings make some changes to the web.config file, these are the relevant sections for the search:
<elmah> <security allowRemoteAccess="false" /> <errorLog type="Elmah.MySqlErrorLog, Elmah" connectionStringName="elmah-mysql" /> </elmah>
This required a new connection string ... elmah already added a template for me, I just needed to insert the correct credentials into:
<connectionStrings> <add name="DevDB" connectionString="Server=localhost; Database=NZ; Uid=myuserid; Pwd=mypwd" providerName="MySql.Data.MySqlClient"/> <add name="elmah-mysql" connectionString="Server=localhost; Database=elmah; Uid=myuserid; Pwd=mypwd" providerName="MySql.Data.MySqlClient" /> </connectionStrings>
Make sure EntityFramework provider is correct if you use EntityFramework
<entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework>
and DbProviderFactories are correct.
<system.data> <DbProviderFactories> <remove invariant="MySql.Data.MySqlClient" /> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> </DbProviderFactories> </system.data>
- Get the appropriate SQL Script from here: elmah.Mysql and run Script to create the table and procedures. Also note that these Scripts by default create a database named elmah ... if you want to change the db name, make sure it matches your db in the connection string above.
And all I had to do to run it.
Note One thing to watch out for is to use lowercase characters for your database name in the connection string above, since DB DB names have lowercase values ββ... It really worked for me with uppercase, but then it broke, and I had to change it.
Sarhang
source share