locked
WCF Entity Framework DataAnnotations MVC WPF RRS feed

  • Question

  • Hi there

    I am looking out for a good gudiance on designing the diferent layers of an modern application. By modern application I mean a .NET 4.0 based app, whcih uses the domain design priciple using the entity framework, services using the WCF and front end implemented in MVC & WPF with the help of some popular design patterns like Repository, Unit of work.

    What I got till  now for my POC is

    • the data layer using the Entity Framework Code First, implemented using Repository & unit of work pattern.
    • The MVC application is also ready with one controller & a Index method.
    • The business layer that defines some entities (Business Entities BE/DTO) and some business process classes.

    Now I want to have a WCF service which will expose the functionality over one of the endpoint.

    The issue that I am facing is the how should I exposed my data over the service?

    • exposing my EF model doesnt seems to be good idea since my model would get exposed to other layers.
    • This leaves me the option to translate all my data entities into business entities before sending them over the service to clients. Here I am losing the DataAnnotations capability of the framework, since the validation attributes dont get serialize and will not be available to clients. (They wil start imposing there own validation). Also is it a good idea to expose my BE/DTO as DataContract usign WCF service or should I have a DataContract as well.

    I am looking for guidance on how to make the DataAnnoations functionality impose by server on clients thorugh WCf service? Since the MVC and WPF already have builtin support for them.

    Please advise.


    Pravin Chandankhede
    Monday, November 21, 2011 12:29 PM

All replies

  • Hi,

    Are your services exposed to public or only for internal applications? 

    If you are using services for your applications, best approach is i guess, to keep dataannotation part across layers, having DTO entities layer,  that can be refered by MVC and WPF as well. 

    This gives you easier maintenance, only one place you have to control on validations. After all you are just having reference.

     


    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".
    Thursday, December 1, 2011 1:12 PM