Note that there are some explanatory texts on larger screens.

plurals
  1. POUse WCF Data Contract as model for MVC view
    primarykey
    data
    text
    <p>I have started working on an application which is structured as follows:</p> <p>UI - ASP.Net MVC web application Service Layer - WCF Entities - a simple class library (exposed by WCF layer) Data Layer - for database interactions.</p> <p>Till now, I was defining my models in Models folder of my web application, but now as we have decided to expose them by WCF service (as this application will be consumed by other applications as well), I need some help here.</p> <p>I tried putting all my model definitions in Entity layer which is exposed by WCF service decorating them with data annotations as well as DataContract attributes. Now, I am able to reference these entities to bind them with my views. But, data annotation validations are not working for me.</p> <p>Can anybody please help me for a workaround for this ? I have been searching through web for solution but almost all tell me to put a reference of entity layer in web application which will be tight coupling that we do not want. and the other option is to redefine all entities with data annotations in models folder of my web application,which will be duplicate kind of coding.</p> <p>Is there any better approach for this? Any help appreciated.</p> <p><strong>Update:</strong></p> <p>To consume WCF entities, I have put a service reference in my web application. Now, just to check I modified that Reference.cs file by decorating my data Member explicitly with [Required] attribute and it is working fine. but, I understand these changes will go away whenever service code is generated.</p> <p>Is there any way I can bring that Data annotation attribute here? Kindly help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload