Adding MySql.Data.MySqlClient to DBProviderFactories in ADO.NET

Today I had an opportunity to travel back in time all the way to 2005 and work with the classic ADO.NET classes in .NET. Needless to say, I’d forgotten everything about it…

The end goal was to create a control that can connect to different databases, even different types of databases, and execute the same SQL commands based on some condition. Basically it was, at last, that real-world scenario all the ASP.NET and C# books from back in the day said just might come up some day. It only took 8 years!

Anyway, my first step was to verify that I did indeed have all my data providers in the ADO.NET DbFactories, as I needed to cover SQL Server, Oracle, and MySQL. Fortunately I quickly found this old article which laid it out for me.

View full snippet on Gist.

When I ran that, I noticed that the MySql provider was missing, which was unexpected because I did have the MySql.Data assembly (which contains the MySql .Net Connector) in my project. After a bit more searching I found this helpful StackOverflow thread: ASP.NET and MySQL .Net Framework Data Provider Issues.

It reminded me that I also have to add that Provider to the node in web.config, as shown here:

View full snippet on Gist.

Once I added that to my web.config, I was able to see it in the list of providers above.

Now I’m ready to rock!

Check if a Sitefinity Module is Installed or Disabled

When working with the Sitefinity API and its various Content Managers, you need to make sure and consider the fact that after version 5.1, users have the ability to disable modules. Attempting to access the content manager of a disabled module will result in an exception.