In this article you will learn how to make a WCF RIA Service and how to consume that using Visual Studio LightSwitch 2012.
What is WCF RIA Service
RIA services is a server-side technology that automatically generates client-side (Silverlight) objects that take care of the communication with the server for you and provide client-side validation. The main object inside a RIA service is a DomainService, usually a LinqToEntitiesDomainService that is connected to a LinqToEntities model.
Getting Started
- Open Visual Studio 2012.
- Go to "File" => "New" => "Project..."
- Select "LightSwitch" in installed templates.
- Select "LightSwitch Application (Visual C#)".
- Enter the Name and choose the location.
- Click "OK".
First of all let's create a new Class Library, right-click on the solution and "Add" => "New Project". 
Image 1.
Now add a new ADO.NET Entity Data Model using right-click and click "Add" => "New item".
Image 3.
Choose Model Contents and click "Next".
Image 4.
Choose your data connection.
Image 5.
Now choose your database objects and settings and click "Finish".
Image 6.
Image 7.
Now right-click on the Class Library and click "Add" => "New Item" and select "Domain Service Class" and edit the name then click the "Add" button.
Image 8.
Image 9.
If you don't see your context class in the drop down, then read this:
With Visual Studio 2012, Entity Framework now creates "DbContext" based context classes by default, but WCF RIA Services does not support "DbContext" based context classes. In order to utilize your Entity Framework model with WCF RIA Services, you must convert it to an "ObjectContext" based model. This can be done using the following steps:
1. Open your entity model in the designer, change the "Code Generation Strategy" from "None" to "Default"
2. Delete the two ".tt" files that are adjacent to the model
3. Rebuild the project
Image 10.
After following those steps, you will be able to select your entity model's context class in the "Available context classes" list. The side-effect of this procedure is that you have now converted your entity model from an Entity Framework DbContext-based model to an ObjectContext-based model. Now again add a new Domain Service Class and click "Ok". 
Image 11.
As you can see, your data context class in drop and uncheck Enable client access and select the entity and check "Enable editing" if you want to edit and click OK.
Now open the domain service class and add Isdefault.
// TODO:
// Consider constraining the results of your query method. If you need additional input you can
// add parameters to this method or create additional query methods with different names.
// To support paging you will need to add ordering to the 'Customers' query.
[Query(IsDefault=true)]













Behdad PedroodPosted Nov 17, 2013, 5:53 AM
Thanks for this useful article, You said we should copy the connection string (Image 18) but where should we paste it?
anupPosted May 8, 2013, 8:06 PM
I have created an application by following your instruction. But I am only able to see the data but cannot edit.