If you automatically generate code, you have a maintenance problem. You must restore it again when you change the interface or any server configuration.
For this reason, I NEVER create a client from the exposed metadata.
An interface must be defined in one library. Call this MyContractsLib library. The service implementation must be in a separate assembly (which I will call MyContractsImplementation ). The client must move to another assembly.
Then the client must use ChannelFactory to create the service.
var cf = new ChannelFactory<MyContractsLib.MyContract>(this.EndpointName); MyContractsLib.MyContract serviceProxy = cf.CreateChannel();
The only scenario in which this is justified is if the service is developed by a third-party organization and you yourself write a client application.
If you have the time and inclination, see this presentation goes in depth.
source share