Feb 29

Written by: Michael Washington
2/29/2012 12:54 PM  RssIcon

clip_image001

Many of you have discovered the power of using WCF RIA Services that are simply pointing to the internal LightSwitch database. The LightSwitchHelpWebsite.com has covered this in the articles:

WCF RIA Service: Combining Two Tables

Using WCF RIA Services In LightSwitch To Simplify Your Application UI

In LightSwitch 11 you have to make a slight change. Instead of linking to the ApplicationData.cs file in the ServerGenerated project, you need to link to it in the Server project.

The Problem

To demonstrate this, we will start with the code from: Using WCF RIA Services In LightSwitch To Simplify Your Application UI.

clip_image002

When we look at the Visual Studio 2010 version of the project, we see that there are two directories ClientGenerated and ServerGenerated that are not used in Visual Studio 2011.

clip_image003

When we open the project in Visual Studio LightSwitch 2011 it prompts us to upgrade.

clip_image004

When the project opens and we switch to File View

clip_image005

… we see that the ClientGenerated and ServerGenerated directories are no longer a part of the project.

However, if we look on the hard drive the directories are still there.

clip_image006

If we run the application at this point we get an error with the dreaded Red X.

clip_image007

The error is:

Mapping and metadata information could not be found for EntityType 'ApplicationData.Implementation.NorthWarehouse'.

The Fix

clip_image008

Jewel Lambert pointed out the answer. Basically the reference to the ApplicationData.cs file is now pointing to the wrong place.

clip_image009

First, we remove the ApplicationData.cs file in the WCF RIA Project.

clip_image010

We then Add a Existing Item…

clip_image011

We then navigate to the ApplicationData.cs file in the Server project (..\Server\GeneratedArtifacts\ApplicationData.cs) and Add As Link (we add as link so the class will be automatically updated in the WCF RIA Service when it is changed by LightSwitch).

clip_image012

When we run the application now, it works.

4 comment(s) so far...


Gravatar

Re: Using WCF RIA Services With LightSwitch 11

Yes! Saved my day! When I discovered this issue I knew where to find the right answer: http://lightswitchhelpwebsite.com/
Thank you!

By Tobias on   3/7/2012 5:15 AM
Gravatar

Re: Using WCF RIA Services With LightSwitch 11

When I've been away from any kind of non-routine programming for say, over a week (ok, a month), I always expect it to be a big pain to get back up to speed. And, disappointingly, I'm usually not disappointed. But that was the bad old days.

Reviewing my WCF RIA Services resources today reminded me once again that with you around it just doesn't matter. Speed, schmeed, code it up and modify as required. You're the best.

By Richard Waddell on   9/16/2012 7:18 PM
Gravatar

Re: Using WCF RIA Services With LightSwitch 11

Interesting article...

but i hava a little trouble with the implementation of the RIA services.

i have LS 2011 and VS 2012 RTM, and simply, i don't know how to ADD a proyect like the example in VS2010. i'm deployment the entire application in this configuration, and i need to execute specifycs query's to get some data

can anyone help me with this.... appling a RIA from the begining.

By Eduardo on   9/19/2012 8:22 AM
Gravatar

Re: Using WCF RIA Services With LightSwitch 11

Thanks.

By Gabriel Marazzi on   11/28/2013 12:35 PM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 
Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation