2

I'm sure this goes all the way back to the very basics but I'm curious:

I have a dll that handles entity framework connections to the database. ie my model is in this dll along with a static class to help govern CRUD methods or validations.

My question is: Once I've made a reference to this dll, why must I include the ModelEntites connection string in my consuming application's app.config file when this has already been done within the dll's app.config file?

MegaMark
  • 600
  • 8
  • 26

1 Answers1

3

Shared libraries do not have separate app.configs, as the app.config is an application level config file. So any settings you want to set at the app.config level for your shared libraries (including connection strings) need to happen in the current application's app.config.

While you may have an app.config file in your shared library, it will not be used automatically by the .NET framework. There are ways to include it if you really need to, but in my opinion they are probably more trouble than just including the relevant info in the standard app.config for each application using the library.

Community
  • 1
  • 1
jball
  • 24,791
  • 9
  • 70
  • 92
  • Can't give a point for that as I have not yet received enough reputation but this is a good answer and makes sense so thank you and +1 IMHO – MegaMark Apr 22 '13 at 20:50
  • Is there any kind of work around for this? If someone gave me their version of the same dll but didn't bother to give me the connection string... how would I use that dll? – MegaMark Apr 22 '13 at 20:51
  • 2
    By design it would use the connection string from your application, as typically you want to use libraries against the resources of the current application, not some static resource. I have never seen a situation where the connection string should be static. – jball Apr 22 '13 at 20:53
  • OH!!!! Okay I think it just went 'click' for me and yeah that makes so much sense now... Got it Thanks again – MegaMark Apr 22 '13 at 20:56