If you define both the client and the service, you do not need to use the WSDL generation classes. Move the shared objects to a separate assembly and refer to it from both client and server projects. When you create a link to a service, there is an βadvancedβ option (in my opinion, enabled by default) that reuses any known classes from WSDL instead of generating new ones.
Even better, if you move the service contract to your shared library, you donβt even need to create a link to the service, you can just call ChannelFactory
directly and exclude the entire automatically generated proxy class.
I have a demo of how to do both of these things on my blog: http://blog.kutulu.org/2012/03/proxy-free-wcf-ditching-proxy.html
If you absolutely need to use WSDL from the service (for example, you do not have control over the service and it can change for you), you can extend the partial classes created by VS (as you suggested). Most of the auto-generated classes that you get from VS these days are partial classes, specifically to make such an extension possible. The disadvantage, of course, is that nothing guarantees that the client and additional methods of the partial class will be the same. I would definitely think that this is a variant of the last resort.
source share