Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,
I have some confusion while design MVC and WCF application.Can we use Data Contract in WCF as Domain Model in MVC so that not to repeat the code of Model.Can you please suggest me whether use Data Contract as WCF Model.Suggest best approach to do this kind of scenario.

Thanks
Dinesh Sharma
Posted

1 solution

You could, but it is kind of fragile. If anything changes in the wcf model, everything using that model needs to adapt to that. But if you use another model for MVC you just have to only change the mapping between wcf and the mvc model.
For example, using Name from the wcf model in several views. Now the wcf model changes Name to ProductName and you need to change every Name reference to ProductName instead of only changing the mapping in your mvc model. Because both models will look alike, you can use AutoMapper for easy mapping between the models.

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900