3

I have an App.config where I would like to replace the provider specified in machine.config with a different version of the provider. I have tried removing the provider by name with remove and have now tried removing them all with clear.

This seems to have no effect: The connection string is still loading the provider specified in machine.config. For example, when use the configuration below, I expect the application not to find my provider.

<system.data>
    <DbProviderFactories>
      <clear />
  </system.data>

Further, specifying a different name or trying to override the same name; also has no effect.

<system.data>
    <DbProviderFactories>
      <clear />
      <add name="MySQL Data Provider" invariant="testprovider" description=".Net Framework Data Provider for MySQL"
                       type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>
Brian
  • 6,910
  • 8
  • 44
  • 82

1 Answers1

4

You cannot remove the provider by "name". You must remove it with its "invariant" name instead.

Example:

<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.3.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
  </DbProviderFactories>
</system.data>
Mark
  • 450
  • 2
  • 10