(.NET 2.0) Adding your own DataProvider to the DbProviderFactory model.

S

Sahil Malik

I'm sorry for my incessant questions but I am architecting a Sql Server
2005/ADO.NET 2.0 project, and I just wanna be double sure of any
architecture decisions I make.

I found the following very interesting code in
DbProviderFactories.Initialize() --

DbProviderFactories._configTable =
ConfigurationSettings.GetConfig("system.data") as DataSet;

In my further snooping around, I found the following section in my
Machine.Config

<system.data>
<DbProviderFactories>
<add name="Odbc Data Provider" invariant="System.Data.Odbc"
support="BF" description=".Net Framework Data Provider for Odbc"
type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.3600.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add name="OleDb Data Provider" invariant="System.Data.OleDb"
support="BF" description=".Net Framework Data Provider for OleDb"
type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.3600.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add name="OracleClient Data Provider"
invariant="System.Data.OracleClient" support="BF" description=".Net
Framework Data Provider for Oracle"
type="System.Data.OracleClient.OracleClientFactory,
System.Data.OracleClient, Version=2.0.3600.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
<add name="SqlClient Data Provider" invariant="System.Data.SqlClient"
support="FF" description=".Net Framework Data Provider for SqlServer"
type="System.Data.SqlClient.SqlClientFactory, System.Data,
Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add name="SQL Server CE Data Provider"
invariant="Microsoft.SqlServerCe.Client" support="3F7" description=".NET
Framework Data Provider for Microsoft SQL Server 2005 Mobile Edition"
type="Microsoft.SqlServerCe.Client.SqlCeClientFactory,
Microsoft.SqlServerCe.Client, Version=9.0.242.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>

Wait a minute !!! Does this mean that in order for my very own custom Data
Provider to appear as available inside DbProviderFactory model, I need to
specify it via config files?

Am I barking up the wrong tree here? Is that not the right way to do this?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
D

David Sceppa

Sahil,

That's the right tree. The DbProviderFactories class uses the
DbProviderFactories area of the configuration data loaded in your
application.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2004 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top