I am using DbProviderFactories in my data layer (based on Entity Framework) and am using SQLite for my database, but I don't have to have a App.Config to have the following code:
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
Instead I would like to have my data layer put that in programmatically. Anyone know a way to do this?
EDIT:
The reason for this is that I am using a IoC container to pick the data layer and some of my data layers don't need the App.Config values, or have them be hard tied to the data layer.
Even Later Answer
Get it using configuration like above. I've found that this seems to require the provider assembly to be somewhere that the running program can find it.
Another method that gets the Instance field directly from the assembly. It works even when the DLL is somewhere else on the system.