Issue with SubSonic and Multiple Providers

subsonic

I have two Subsonic-generated Data Access Layers for 2 different databases that I use in one project and so I have the following in my web.config:

<SubSonicService>
    <providers>
      <add name="BLLDB" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="BLLDB" generatedNamespace="BLLDB" useSPs="true" />
      <add name="BLLDB2" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="BLLDB2" generatedNamespace="BLLDB2" useSPs="true" />
    </providers>
  </SubSonicService>

yet, anytime I call the code for either DAL it always ends up using the second data Provider listed ("BLLDB2"), and so gives an error like "Invalid object name 'dbo.Users'" when it should be reading from "BLLDB" (despite me explicitly specifying "BLLDB" in the Select())

e.g. check the following code for the "BLLDB" DAL:

Dim mySelect As New
SubSonic.Select(Databases.BLLDB)
mySelect.From(Of User)()

"mySelect.ProviderName" returns a string value: "BLLDB2"

whereas "Databases.BLLDB" returns a string value: "BLLDB"

what gives??

Best Answer

One of your provider is failing. Subsonic is not good about telling you why and where its failing.

I usually debug in couple of ways.

  1. Use only one provider at a time and comment the other one. Check if you are able to see the namespace. If both of them load fine, then you atleast know its not the database.

  2. Check if any of you tables start with -, _, or numbers. This can cause it fail as well.

Let me know how it goes.

Related Topic