I’ve developed a contract for WCF. It has a database connection. So I like to connect with 2 different databases with 2 different services. So how can I host that contract with 2 different configurations (like database name, username, password) as 2 services in 2 different addresses?
For Example
I have a contract called DataHandler.
Now I have to register them as 2 services on a system,
First service can access databse1 and second service can access database2
I can’t give database1 & database2 as a parameter from client application.
So how to solve this problem?
Can I give any parameter to service contract from hosting server?
Use one service with single endpoint and single configuration and deploy this service to two different applications each providing correct configuration. It seems like a strange solution but it is the simplest one and in many scenarios also the correct one. It also provides the best separation between two configurations.