I'm redesigning a WCF Windows Service (InstanceContextMode.Single) which was created by an external supplier, while it was super urgent and when there wasn't really much time to design the software. That means that the code was kind of a patch-up job. Now I want to redesign it properly.
Originally, the service just forwarded requests from a light weight client to external web services, hosted by some other supplier companies. Additionally, the service logged all requests (for legal issues and troubleshooting). The service was implemented with a plugin pattern. Every plugin (a single dll) registers at the service. A request from the client will be forwarded to the target plugin according to a token. In case one of the plugins can't reach its external supplier service, it accesses to a local database which stores a copy of the data (but which only gets updated once a day, so the data isn't 100% up to date). The webservice is mostly stable, but we have to restart it from time to time due to memory leaks caused by the way how it was patched together.
However, the requirements changed a lot and now we'll have another 6 plugins which don't forward to an external web service at all. Instead, they directly access the database to get the data. Unfortunatly, the way how the service was designed so far, needed all of the plugins to have their own implementation of the database connection and queries. That means, if I create 6 new plugins, I have to write code for all of them for database connection and queries, etc. It will be a lot of redundant code. That's why I thought, I could abandon all these SQLConnection and SQLCommand stuff and just use EntityFramework instead. Since the database already exists, I can use the Database First approach and generate the code.
My problem (sorry for the long intro) is now, that the whole concept of the software was designed with the plugin pattern. That means, if I have original 3 plugins accessing the database and another 6 new plugins accessing the database, I need to handle 9 plugins in total. So either I create 9 edmx files, but they all must be updated whenever the database changes. Or alternativly, I add one database project and all the 9 plugins reference to this project and let it handle the database stuff. But then the whole concept of the plugin pattern is kind of lost, isn't it?