views:

91

answers:

2

I am using SubSonic 3.0.0.3 (the ActiveRecord approach) in an HttpHandler that I have in its own library. For it to work in the end, I have to have the connection string in the website's web.config instead of the class library's app.config. Is this the expected result or a bug?

+3  A: 

Using Reflector, I checked out SubSonic's ProviderFactory.GetProvider(connectionStringName) method, which is what is called in your generated Db/Context class' constructor.

It uses the ConfigurationManager to look for connection strings (as expected). So, when you're running a web app, it will be looking in the web.config file for known connection strings. You'll need to copy your connection string configuration into the .config file for the application that is using your .dll.

womp
+6  A: 

The only config that gets picked up is the execution environment's configuration - storing this in the class lib won't work - for any config setting.

You can override our template behavior by sending in a connection string using ProviderFactory (as above).

Rob Conery
That was not obvious to me. Thanks!
JasonFruit