I have a ASP.NET MVC applicatio开发者_运维百科n which is build up as an assembly that queries the database and a asp.net frontend that references this assembly and this assembly abstracts the underlying database. This means that my Assembly contains a app.config file that contains the connectionstring to the database (Linq to SQL data model). How do I go about making this more flexible? Should I make a "initialize()" method somewhere in my assembly which takes the connection string from the asp.net MVC application and then that controls which database to use? or how is this done?
You can create a setting for that assembly in the project properties. However, you really shouldn't have things configured statically like that. It should be possible to create two systems of objects from your assembly that each point toward a different database without either affecting the other.
精彩评论