2/29/2012 12:54 PM
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.
To demonstrate this, we will start with the code from: Using WCF RIA Services In LightSwitch To Simplify Your Application UI.
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.
When we open the project in Visual Studio LightSwitch 2011 it prompts us to upgrade.
When the project opens and we switch to File View …
… 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.
If we run the application at this point we get an error with the dreaded Red X.
The error is:
Mapping and metadata information could not be found for EntityType 'ApplicationData.Implementation.NorthWarehouse'.
Jewel Lambert pointed out the answer. Basically the reference to the ApplicationData.cs file is now pointing to the wrong place.
First, we remove the ApplicationData.cs file in the WCF RIA Project.
We then Add a Existing Item…
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).
When we run the application now, it works.
4 comment(s) so far...
By Tobias on
3/7/2012 5:15 AM
Yes! Saved my day! When I discovered this issue I knew where to find the right answer: http://lightswitchhelpwebsite.com/
By Richard Waddell on
9/16/2012 7:18 PM
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 Eduardo on
9/19/2012 8:22 AM
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 Gabriel Marazzi on
11/28/2013 12:35 PM