About My Blog



Whenever I get stuck doing something - the time comes to venture in the world of internet to find solution. In most cases I do find the solution, solve my problem and go on with my life. Then one day I am faced with the same problem. But now - I can't remember how the hell I solved it the first time. So the cycle begins again. Then I thought, what if I can remember all the those things? So here it is, my Auxiliary Memory. I decided to save all the problems and their solution in this blog so that I can get back to them when I need them. And the plus point is - so can everybody else.

Thursday, November 13, 2014

How to list DB Provider Factories registered in machine with C#

Recently I was trying to use Entity Framework with Oracle Database. In one point I needed to see the DB Provider Factories registered in my machine. In one of the blog I found how to do that using C#(Sorry I forgot to save the link). What they did was create a desktop application and used a datagrid to show the result. It looked like a lot of work to just get the names. So, instead, I used LINQPad. Basically, it's like a Sql IDE which can execute C# codes on the fly. So you can just open up LINQPad, write some code, and see the result on the fly. I even use it to get some scripting jobs done instead of using powershell or cmd.
To get the list just fire up LINQPad. Select "C# Statement(s)" from "Language" dropdownlist. Paste the following line in textarea and run.
System.Data.Common.DbProviderFactories.GetFactoryClasses().Dump();

You will be presented with the details of all DB Provider Factories in your machine.

No comments:

Post a Comment