RIA Services: Jumpstarting RIA Development

A run through of the tooling features in VS2010 that complement RIA Services to offer RAD for RIA, and options for going beyond the basic starting point ...

Screenshot of finished Contacts applicationIn my post on RIA Services: From Vision to Architecture, a while back (right after MIX09), I mentioned that I like to think of RIA Services as RAD for RIA. At that point we had a very early preview of framework bits with little tools support. A large part of jumpstarting your development actually centers around good tooling. VS2010 brings tooling for RIA Services (now: WCF RIA Services).

Scott Hanselman demonstrated some key features used in building a Contacts application (as shown on the right) during the keynote at PDC09.

The latest version of RIA Services is now available for download. It works on .NET 4 and VS2010 as well. You can also check out a video tutorial on using RIA Services and Visual Studio 2010.

In this post, I want to highlight the range of tooling features that span from the start to getting an application up and running.


Business Application Template

New Project - Business Application Template

Client and Server Projects in SolutionThis template has come to have a life of its own. Folks love it. Sometimes I wonder if we'll see a bunch of RIA Services applications that all look like the business application template (we need to get an updated set of themes/variations on the look/feel of the app). However, it does reflect how it is a useful starting point.

The template results in a solution with two projects that together represent your end-to-end application - an ASP.NET Web application representing the server half, and a Silverlight application representing the client. The two projects are linked. The client project logically depends on the server project, so services in the server can automatically be consumed without additional explicit references, and the client project is set to be deployed back into the server project.


DataModel

OK, so this isn't part of RIA Services specifically, but it is certainly a key part of the application development flow. RIA Services allows you to use your choice of data access technology, and you get to use both the runtime APIs, and its design experiences.

Contacts Entity Framework Data Model


New DomainService

DomainService WizardThe role of a DomainService class is to encapsulate your data access logic, and any application-specific logic. It is typically a stateless service with a set of CRUD methods. DomainService represents the starting point for RIA Services specific functionality.

The wizard allows you to get started with a basic DomainService with a ready-to-use initial implementation of CRUD methods that operate on the data model and entities you select to expose to the client.


Client-side Programming Model and Intellisense

The RIA Services infrastructure automatically produces a strongly-typed, data-centric proxy in the form of a DomainContext for each DomainService exposed by the server half of the application. You don't have to explicitly add references, or perform an explicit build. It just works, just as you'd expect things to work within a single project... the only difference is that this time its within a single application across couple projects in the solution.

Intellisense against generated DomainContext


Data Sources Window

The Data Sources window understands the RIA Services programming model, and surfaces the generated DomainContext and Entity types, so you can easily drag them onto the design surface to create data source controls, and data-bound lists and details user interfaces, that support browsing data, sorting and paging through it, editing it (with validation), and exploring master/details relationships.

Data Sources Window and Drag/Drop Data



All of these design-time features complement RIA Services to simplify application development to allow you to quickly get started and create a breadth-first version of your application's functionality. Usually this isn't the end, so RIA Services lets you go much further depending on your scenarios, and requirements. Here are a few things that might interest you.

  • Structured Queries and Operations: instead of having default CRUD methods, you might choose to create one or more structured query methods, custom update methods etc. to closely match the semantics of your particular application domain.
  • Validation, Authorization and Business rules: More than likely you'll have a few interesting rules to enforce. You can define them using metadata that you attach to your models and your methods. This metadata can be specified using CLR attributes, or read-in from external storage such as a database or rules engine. Either way, RIA Services takes care of propagating your intent down to the client when possible.
  • Presentation model: instead of having your data model entities show up directly on the client, you might choose to create a set of presentation-tier types (or DTOs) that you use to define the contract between the presentation logic on the client and the application logic on the server.
  • Structuring your solution: You might be interested in splitting your models and DomainServices into multiple class libraries. You can create a Silverlight class library for each server class library and then use your n-tier components as a pair within one or more n-tier apps.
  • Creating view models: The client-side programming model of RIA Services lends itself well to the view model pattern, which allows you to factor out your data access logic, and view-independent logic out of your views.


If you've been using RIA Services, hopefully you'll see the new tooling features as rounding out the story. If you're new to the technology, hopefully this shows how RIA Services can take care of lots of plumbing and infrastructure, and allow you to focus on creating your rich internet application simply and effectively.

Posted on Thursday, 11/19/2009 @ 1:03 AM | #Silverlight


Comments

34 comments have been posted.

Steve

Posted on 11/19/2009 @ 5:12 AM
Great stuff Nikhil.

I must say though, I'm very disappointed in the lack of good input controls. Monetary mask controls (I don't consider a numeric 'up/down' control to be the same), mask controls, etc... I see data validation on the samples with (123)444-3242 and yet, there is no mask for it. I don't know many users that will enjoy typing in a mask :)

To have such rich 'graphs and charts' and no fundamental data entry controls still gives the 'this is not ready to really build a business app with'. I build business apps, many times with data entry features. These current input controls are not up to snuff.

Thanks

Salman Farsi

Posted on 11/19/2009 @ 6:19 AM
Hi,

It is really becomes RAD, wow, good stuff.

Thanks

Helen Warn

Posted on 11/20/2009 @ 7:29 AM
I am using RIA Services in a Silverlight 3 project that I want to deploy. However the hosting environment is partial trust. Will the current version of RIA Services for VS 2008 and .Net 3.51 work in this environment? If not I will be forced to rip it all out and revert back to WCF.

jsp3536

Posted on 11/21/2009 @ 1:51 PM
Do you have an update for the LocalDomainClient that you posted on the previous version to help with unit testing?

Werner

Posted on 11/23/2009 @ 2:18 AM
I am poking around with RIA now in vs2010.

Some questions that came up that I could not find any details on the internet on.

#1: All the demo's and such use databases that are rather small and fairly obvious. Columns have proper names and they contain generally helpful human readable data(not foreign keys to human readable data). How would one handle situations where there is a column say "Type" that contains a foreign key into a Type table that has a Human readable column of what the type actually is? Is this possible? How would update work when such data is displayed in a datagrid.

#2: Is there a way to alter the column names in the Entity Data Model or further down the road? What if some existing database has weird naming conventions on its columns that look silly when it gets automatically sucked onto a datagrid. Can I set it somewhere like you can set what Silverlight control to use for each data column? What is the best way to handle this?

Duncan Watts

Posted on 11/23/2009 @ 6:31 AM
@Werner

#1: Using Entity Framework it can pick up foreign keys and create navigation properties so that your entity contains a list of foreign keyed entities or a single entity, etc. These can be included and sent to the client. I have gone down the route of creating views which perform the joins and retrieve the relevant table from the linked tables.

#2: Yes, you just click on the entity and rename them. You can also set AutoGenerateColumns to false and specify the type of column (Text, checkbox, hyperlink, completely custom, etc) and binding in the DataGrid. Try http://blogs.msdn.com/scmorris/archive/2008/03/27/defining-columns-for-a-silverlight-datagrid.aspx

Nikhil Kothari

Posted on 11/23/2009 @ 9:15 AM
@Werner
For creating projections like these, you have two options: (a) create a new type that aggregates information from multiple tables. Alternatively for simple scenarios (b), you can use the [Include] attribute to specify that you want to include a member of an associated entity into the main entity to send to the client. Eg. [Include("Name", "TypeName")] - includes Name of your Type entity as TypeName member on the parent entity.

For #2, you can try using the [Display] attribute to specify display names.

Werner

Posted on 11/23/2009 @ 11:53 AM
Thanks!

I have come across your suggestion of creating aggregate types on some Entity Framework related topics, and if you recommend it I am satisfied that this way is currently the best way of handling such cases.

What is interesting to me is that intuitively I expected to create a new import function, make entity framework create a new complex return type for it, and then have RIA detect it like it does entities when I add a new Domain Service. However, it does not work this way.

It feels to me that all the information necessary to make it work is there? Is there a possibility that RIA 2.0 might include such functionality, or are there technicalities that would make such import functions unusable to RIA.

Nikhil Kothari

Posted on 11/23/2009 @ 11:18 PM
@Werner
I am not too familiar about import functions, but let me say this.

The new DomainService wizard is simply a starting point, and as such is very basic. You should be able to use any EntityFramework features you need to within your DomainService implementation. As long as your CRUD methods return or accept entities, what you do to instantiate them or do with them to perform processing logic, is up to you...

Werner

Posted on 11/24/2009 @ 12:39 AM
Interesting.

It is nice to hear you say this. Otherwise I would immediately assume that the wizard fully utilizes what a domain service can provide. I guess I was wrongly under the impression that the goal of RIA was to allow a programmer to drive the data layer with just a mouse. ( I think it does a spectacular job at this for a variety type of websites already)

I hope I will be able to figure out some goodies that will help me make more complex LOB websites with RIA.

;)

Sathyan

Posted on 11/25/2009 @ 3:26 AM
Hi Nikhil,
This is a very nicely written article on a really great feature. Unfortunately, I am not seeing the domain data services as Data Sources in my Data Source Panel - Running with VS 2010 Beta 2, SL 4 SDK, latest RIA - The projects build successfully but I just do not get the data sources.
Any thoughts on this would be of great help. I really want to get this working. Thank You.

Werner

Posted on 11/25/2009 @ 5:12 AM
@Sathyan

What do you see under your silverlight project -> Properties -> Datasources? Is there an entry there?

I am using the same versions you are and its working fine... must be something on your side.

Sathyan

Posted on 11/25/2009 @ 8:11 AM
Hi Werner,
Err I dont see DataSources under silverlight project -> Properties. All I see is AppManifest.xml, AssemblyInfo.cs, OutOfBrowserSettings.xml Under silverlight project -> Properties. What does this mean? What am I missing?
Thanks,
Sathyan.

Werner

Posted on 11/25/2009 @ 8:20 AM
@Sathyan
mmm...

Select Data in the menu -> Show Data Sources

And make sure when you right click properties on your silverlight project you have .Net RIA services link set to the .Web project on the silverlight tab.

It should just work?!

Sathyan

Posted on 11/25/2009 @ 9:08 AM
Hi Werne,
silverlight project you have .Net RIA services link set to the .Web project on the silverlight - This is Set - This was Fine
Dat Sources - they just don't populate :(
Qn: What did you install apart from VS 2010 Beta 2? This is what I did - Uninstalled the RIA preview for VS 2010, installed Silverlight4_Tools_ENU AND RiaServices (1.0.10.14) - is there anything else I need to install?
Thanks Again.

Werner

Posted on 11/25/2009 @ 11:25 AM
Those 3 are all you need. What happened when you selected Show data sources? Things should start to populate when you click that menu item.

Sathyan

Posted on 11/25/2009 @ 9:59 PM
Hi Werner,
Thats exactly the problem - Nothing happens and Nothing populates :( - tried in 3 different machines thus far.

Paul

Posted on 11/27/2009 @ 4:13 AM
I'm seeing exactly the same thing. Data Sources pane is empty.

Nikhil Kothari

Posted on 11/29/2009 @ 10:38 PM
@Sathyan, @Paul
Couple things to make sure - your Silverlight project has a RIA Services link to the web application project (look in project properties of the Silverlight app), and that your solution builds fine. Upon verifying the solution builds, turn on Show All Files in solution explorer for the Silverlight project, and make sure there is some generated code in the Generated Code folder.
Now open up a xaml file, such as Home.xaml, and then bring up the DataSources window from the Data menu... if everything is working as expected, you should see some DomainContext types (the generated ones) listed in the window.

Hope that helps!

Paul

Posted on 12/1/2009 @ 12:42 PM
Hi Nikhil, I've followed all these steps and still the Data Sources pane is empty. Very frustrating.

Joachim

Posted on 12/1/2009 @ 12:48 PM
Hi,
I also have the problem of an Empty Data Sources pane. All code is generated fine as I can use the DomainService from code behind, but the Data Source pane doesn't populate. I'm using the Visual Web Developer express beta 2 on Windows 7...

Roque Vera

Posted on 12/3/2009 @ 5:43 AM
Hi,

Same problem here. I have 3 machines but just 1 with data sources window working.

Any ideas?

Werner

Posted on 12/8/2009 @ 3:55 AM
Maybe, here is some thought.

There seems to be 2 ways to install RIA services preview for VS2010 beta2.

1.) Direct link to the entire thing ( Silverlight 4 toolkit with built in RIA ) @ http://go.microsoft.com/fwlink/?LinkID=177508

OR

2.) Installing the Silverlight 4 toolkit seperately and then the RIA services bit

SL4 Toolkit : http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36060#DownloadId=93513
RIA services standalone: http://www.microsoft.com/downloads/details.aspx?FamilyID=91998faf-d2df-42bb-af2e-17d43d7ce078&displaylang

I installed using option 2. Maybe that helps.

W

Marat

Posted on 12/8/2009 @ 11:38 AM
I have the same problem. The Data Sources window is empty. All code is generated fine as I can use the DomainService from code behind, but the Data Source pane doesn't populate. I'm using the Visual Stuidio 2010 Professional Edition Beta 2.

Marat

John Mathis

Posted on 12/17/2009 @ 3:47 PM
Bumping jsp3536's question above about a LocalDomainClient update... There are some changes required there and I'm not yet up to it. Thanks,
John

James

Posted on 12/23/2009 @ 7:47 AM
Me too on an update to the localdomainclient. Changed the code to build but getting some runtime errors which I can't pinpoint yet.

Abdul Kunnummal

Posted on 1/4/2010 @ 1:31 PM
Hi,

Did anybody found a solution for missing data source. I have installed and re-installed all tools (In both ways described above) 4-5 times. It works fine with code behind. But, no data sources visible. Any suggestions?

Thanks in advance.

-Abdul

Tim

Posted on 1/19/2010 @ 1:32 PM
I don't have the option to show data sources under the data menu. What's up with that?!

Jonathan

Posted on 1/29/2010 @ 5:16 PM
Hello Nikhil, I have successfully developed a Silverlight application with WCF Ria Services. However, I have encountered numerous problems in the production server after publishing. It was tested to work flawlessly in the local environment. Any idea why this is the case? Could you please check out the following thread that I have made? http://forums.silverlight.net/forums/t/158842.aspx

Thank you.

Andrew

Posted on 2/2/2010 @ 11:54 AM
Hi Werner,

After doing Option 2. I am still not able to get the entities to come up in Data Sources.

Nikhil,

- link is there
- solution builds without error
- show all files - has the file in the GeneratedCode folder and the classes is also there

i thought of just adding it as an Object instead, but still it doesn't show there in the Add new data source. Please help. I'm getting frustrated with this simple bug.

Joe

Posted on 2/2/2010 @ 5:55 PM
I am also having the same issue. I have tried this on the beta's for Express 2010, Professional 2010, and Ultimate 2010. I am running Windows 7 Home Premium 64 bit (installed last week so I know it's clean), I have installed Silverlight 4 with toolkit, sdk, tools and ria services. I do not get the data source window populating either. I have followed all of the steps as outlined in the ria services demo video for 2010.

I have the ultimate beta running at work, and it shows the data sources, but it is a 32 bit XP machine. All installs were the same between the two machines accept for windows 7 64 - vs - windows xp 32 and Work has a full blown version of Sql Server installed instead of the Express Edition.

Does anyone have this working on a 64 bit Windows 7 Home Premium using Sql Server Express? Are there some services, tools, or security settings to check to get this to work?

Joe

Posted on 2/3/2010 @ 5:34 AM
One additional note, At work (XP 32 bit) When I create a new Business Application project and compile without changing anything the AuthenticationContext and UserRegistrationContext data sources automatically appear. At home (Windows 7 64 bit) the data sources do not populate. I have tried running VS as an Administrator and normal and nothing seems to work.

Joe

Posted on 2/3/2010 @ 8:14 PM
my previous posts seem to have vanished. no matter.

I am able to get it to work now. I uninstalled everything and cleaned up my registry and reinstalled. This time (the 4th re-install) I took all defaults and installed all options. I then installed silverlight 4 tools (the one with the sdk and ria bundled up in it), then installed the november toolkit and it seems to work fine. all previous installs, I was installing to D: drive, and not selecting all languages.

I suggest you do a full install to the default location then the bundled tools install followed by the november toolkit and see if that fixes it for you.

Joe

Thanigainathan

Posted on 2/15/2010 @ 11:47 PM
Hi,

This is really a wonderful post. These features are very good features introduced with VS2010.

Thanks,
Thanigainathan.S
Post your comment and continue the discussion.