Step By Step Guide to WCF RIA enabled SL4 application with Entity Framework
In my last post we discussed about the concepts of WCF Ria services , this post is continuation of my earlier post.Here we will create a Silverlight 4 based application with WCF RIA services and Entity Framework.Before going through the article make sure you have downloaded the latest SDKs from Microsoft as mention in my last post.
Well we will develop a simple database centric user management system where the admistrator is going to view and edit user detail.For this app we will use remote sqlserver with following tables.
Create the Project
Open VS 2010 , Select Microsft installed Silverlight Business Template and click ok.Once Project Created Compile the application.You will find a structured application with pre defined WCF RIA support .It will also have predefined user registration and login module
Generate Data Model through EF at Server Project
- Add Ado.Net Entity model to server side Project.
- Here i am using remote sql server from shared hosting , so select connection and proceed.
- More detailed description of adding EF can be found from this blog post.
Add Domain Service to Server Project
- Add a new Item to server side project name “UM_Server_DomainService.cs”.Before adding make sure that you have compiled the project.
- This domain service class will expose the data entities and operations of server side project to the client side project
This will add up 2 classes as shown in figure besides.The
- Compile the project , next we will move on the client side project for data binding.
Load controls, using the Data Context at Client side project (Data Binding Through Code)
- If you check the hidden folder “Generated_Code“ you will find auto generated DataContext code for the client.
- From DomainClient we can communicate to the domain service at server.From client side we can perform 3 fundamental kind of operations.such as Query ,Invoke and Submit .(Details regarding it ,is out of scope of this post ,still you can Refer Here)
- So to bind the data Go to Home Page and add a Drag and Drop a combo box.
- Next steps will be –:
Creating a Query Based Operation ,
Assigning Item data source to the control
So the code as above will fetch the data and load the users.
Alternatively we can also use the Drag and Drop feature of VS 2010 to create binding .Simply go to Home page and open the Data Source Navigation pane .
That’s it , is not it cool.For my goodness the whole lots of work suddenly looks so simple, hats off to Microsoft .
Your comments are welcome and more details i will try to post in future.
- Performance tips for RIA Service with Silverlight 4
- Busy Indicator with DomainDataSource control
- Authentication against custom Table In Silverlight4 Using RIA Service
- Data Aggregation Using Presentation Model in RIA and Silverlight 4
- Performing CRUD on Relational Data (Multiple table) using RIA in SL4
- Converting XML data to CLR object using XmlSerializer
- Consuming External WebService from Silverlight Application
- Data Binding in Silverlight with RIA and Entity Framework – Part 3 (Validating Input Data)
- Validating Textbox on Lost Focus in RIA Service,Silverlight4
- Data Binding in Silverlight with RIA and Entity Framework – Part 2 (Updating Data)
About Manas Patnaik (51 posts)
My name is Manas Patnaik as my domain name suggests, and I design & write software. I live in Bangalore. I used to live in Berhampur, Orissa. My e-mail address is manas002002 AT gmail.com.
Well first, there’s a day job at Infosys , Bangalore. There, I work as Technology Analyst .Previously I worked at Relyon Softech Ltd as Software Engineer .Professionally , I am working from last 4 years . My strength as architect and developer is in developing fault-tolerant, highly scalable, high quality enterprise systems. Since 2005 I am developing and deploying on .Net platform, with occassional forays in LISP,J2EE.You can find my resume here.
In any remaining free time, I used to be at community sites for posting solution or else you will find me in kitchen .
If there’s any time left over, i share my experience here in this blog,watch movies or else play strategy games (Rise of Nation my favorite).