SilverlightShow: Creating applications with .NET RIA Service Part 3 - Adding DomainService class Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples en-us SilverlightShow.net estoychev@completit.com (Emil Stoychev) Argotic Syndication Framework, http://www.codeplex.com/Argotic http://www.rssboard.org/rss-specification RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment3850 <p>After adding the domain service class i can't build the project. There are 15 errors in the domainservice.cs file, all of them 'expecting class, delegate, enum, interface, or struct'. Even 'public IQueryable<...> Get...()' has red under it with the associated error being 'expecting class, delegate, enum...' Is my install of VS2010 corrupt? Previous attempts at building a domain service class worked just fine....Any ideas?</p> <p>Mark</p> ( Markus) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Mon, 21 Jun 2010 21:05:16 +0300 Entity Add precedence http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment3532 <span style="font-family: 'times new roman','serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 'times new roman'; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: en-us;">If I have a Domain Service called domainService and it contains the entities Order and Orderitem, I add three records to the Orderitem entity and one record to the Order entity in that order. Then I call </span><span style="font-family: 'courier new'; font-size: 12pt; mso-fareast-font-family: 'times new roman'; mso-fareast-theme-font: minor-latin; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: en-us;">domainService</span><span style="font-family: 'courier new'; font-size: 12pt; mso-fareast-font-family: 'times new roman'; mso-fareast-theme-font: minor-latin; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: ar-sa; mso-no-proof: yes;">.SubmitChanges(); </span><span style="font-family: 'times new roman','serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 'times new roman'; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi; mso-ansi-language: en-us; mso-fareast-language: en-us; mso-bidi-language: en-us;"><span style="mso-spacerun: yes;"> </span>Which records will be written to the database first, this is important as each Order record will be for one or more Orderitem’s, another program will be checking the database every few minutes for new Orders so it is important that the Orderitem records are written to the database first, otherwise an Order record may be read and marked as such but some of its Orderitem records might be missed.</span> ( Tom Brady) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Tue, 04 May 2010 16:37:01 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment3527 <p>Using:<br /> VS 2010 Premium, version 10.0.30319.1<br /> Silverlight 4 Toolkit April 2010<br /> WCF RIA Services V1.0</p> <p>This tutorial does not work! Once you add the DomainService it gives:</p> <p>The "CreateRiaClientFilesTask" task failed unexpectedly.</p> <p>Come on Microsoft, this is just trying to get the first tutorial going!!! Surely the tutorial was fully tested?</p> ( Dave) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Sun, 02 May 2010 21:20:20 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment3311 <p>I get empty domain class context list where as I do have a dbml file.. details of issue: http://forums.silverlight.net/forums/t/170649.aspx</p> <p>Any help on this??</p> ( enableDeepak) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Fri, 26 Mar 2010 05:14:18 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment3193 I'm also having difficulties as Shawn... ( Shaikh) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Tue, 09 Mar 2010 09:11:45 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment2737 I'm on a clean install of VisualStudio08 with sp1 and the newest toolkit.  I follow these steps but my " <pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'courier new',courier,monospace; background-color: #f4f4f4;">manager.Loaded</pre> " does not have a Loaded event.  Has RIA changed since this publication?<br /> ( Shawn) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Wed, 02 Dec 2009 21:20:34 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment2622 <p>No matter what I do I cannot avoid this error: </p> Association named xxx defined on entity type xxxx is invalid: ThisKey property named 'PeopleId' cannot be found.   <p>I just add two tables which have a relationship defined in the database. The primary key (which is a foreign key in the second table) has a space in it. [People Id], but for some reason the error shows as PeopleId. I am really freustrated trying to resolve this. It compiles fine in the web project, but gives the above error when I try to build the solution.</p> <br /> ( Sam) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Wed, 04 Nov 2009 01:45:38 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment2621 <p>To the users having errors with Domain Service Class and other uncontrolled errors with RIA Services:</p> <p>I installed a brand new virtual machine with vs 08 sp1, slight dev. runtime, sdk 3, tools for vs08 sp1, toolkit 3 and ria services for tools vs 08 sp1.</p> <p>Running smoothly as a baby cheek...</p> <p>Other instalations suffered from similar problems.</p> ( miguel delgado) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Wed, 04 Nov 2009 01:23:59 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment2544 <p>I have a regular .NET Class Library project and with in this project, I have dbml LINQ-to-SQL and partial classes for entities and custom methods that performs CRUD opertaions. It is like DataAccess layer and this is being in use with a Win application UI. Now I want to make use of this DA Library project and want to change the UI from Win Application to SL3 application. Here I want to continue with my existing DA layer with SL3 UI.</p> <p> By the way I have my own custom User Athentication functionality. Is it possible to acheive this functionality using RIA Services and SL3 ??</p> <p>Please suggest </p> <p>Thank You.</p> <p> </p> <p> </p> ( Chakris) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Tue, 13 Oct 2009 14:27:48 +0300 RCustom event http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment2263 <p>Hi Would you tell me how to implement a custom server side event that the client can listen to?</p> <p>For example: I have a domainservice that load a list of objects. I would like ot notify the client everytime a single object of teh list is loaded, so i can show a loading progress on the client.</p> <p> </p> <p>Thanks</p> ( Andrea) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Thu, 20 Aug 2009 14:46:49 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1632 disregard last commnet;  "rebuild solution" works. ( HES) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Tue, 02 Jun 2009 17:17:04 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1631 same issue (<span id="ctl00_cphMiddle_ContentPlaceHolderContent_itemComments_dlstComments_ctl26_lblCommentAuthor">Domino </span>/ <span id="ctl00_cphMiddle_ContentPlaceHolderContent_itemComments_dlstComments_ctl28_lblCommentAuthor">MichaelD! </span>/<span id="ctl00_cphMiddle_ContentPlaceHolderContent_itemComments_dlstComments_ctl30_lblCommentAuthor">Jim</span> ) any ideas.... ( HES) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Tue, 02 Jun 2009 17:14:27 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1574 Me too. ( Jim) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Sat, 16 May 2009 11:27:07 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1566 I'm getting the same error Domino is... wtf. :P ( MichaelD!) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Thu, 14 May 2009 15:47:15 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1554 What's up?  Whenever I click "OK" on the "New Domain Service Class" dialog (after adding the new "Domain Service Class" item to my web project), I get an error message in Visual Studio: "Value cannot be null.  Parameter name: namespaceName"  Then Visual Studio reverts back to the "Add New Item" dialog, and what's weird is that in this dialog, under the "Web" templates, there is no longer a "Domain Service Class" template!  I am running Windows Server 2008, and have uninstalled Alexandria.  I'd apprecaite your throughts.  Thanks dude! ( Domino) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Tue, 12 May 2009 13:13:36 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1550 <p>Hello. Thanks for your posts. It's very Useful Posts :)</p> <p>I have a question. (sorry for my poor english)</p> <p> </p> <p>I know that 'xap file' was already installed on client side.</p> <p>If I publish a whole project including silverlight application and Web application on IIS Server, </p> <p>does the 'xap file' recognize Server's modifying codes?</p> <p>I guess the xap file size doesn't change. so, it won't be reload itself.</p> <p>Does it specified any IP Address between GenerateCode Folder(client side) and DomainserviceClass.cs(server side)?</p> ( Shorty) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Mon, 11 May 2009 04:52:53 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1490 <p>Martin, Thanks for the application! I will look forward to the future posts!</p> <p>One question...when I add aspnet_roles table, I get 2 errors while compiling</p> <p> Problem in Mapping Fragments starting at lines 387, 408: Two entities with possibly different keys are mapped to the same row. Ensure these two mapping fragments map both ends of the AssociationSet to the corresponding columns.</p> <p>What am I doing wrong?</p> <span style="font-size: 16px"> <p> </p> <p> </p> </span> <p> </p> ( lilsteps) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Sun, 19 Apr 2009 22:46:19 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1457 That fixed me up, Martin. <p> </p> <p>Thanks!</p> <br /> ( Bill) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Sat, 11 Apr 2009 19:28:52 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1414 <p>Thanks for this series, it's very needed. I have the database attached aspnet.mdf attached to my local sql server.</p> <p>How can I add this database to App_Data folder?</p> <p>Thanks again</p> <p>Rachida Dukes</p> ( Rachida Dukes) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Fri, 03 Apr 2009 12:13:07 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1404 <p>Hi, Gistavo! </p> After creating your data model, be sure to build the project. After the build the model should be available in the DomainService prompt. :) Tell me if that worked for you.<br /> ( Enrai) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Thu, 02 Apr 2009 04:22:32 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1401 Hi <p> </p> When I click to add a New Domain Service Class the "Available DataContexts/ObjectContexts" don't have any item on it. My .edmx file was created but it does not show here. <p> </p> What am I missing ? <p> </p> <p>Thanks</p> <p> </p> <p>Gustavo</p> ( Gustavo) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Wed, 01 Apr 2009 15:15:10 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1372 Hi, biofractal!<br /> <br /> Unfortunately I am still new to the Entity framework and for now there are a lot of things that I am not familiar with - the POCO entities are one of them. Surely I will catch up with the framework soon and will be able to answer your question.<br /> <br /> As for the second question, the .NET RIA Services is freshly released so there aren't a lot demos of it yet. If I happen to find such I will share the link! :)<br /> ( Enrai) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Tue, 31 Mar 2009 07:03:57 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1309 Is it possible to use the DomainService class to interact with POCO domain entities? Do you know of any examples of a DomainService class being used from a Domain-Driven perspective? Thank you. ( biofractal) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Thu, 26 Mar 2009 19:07:44 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1286 Thanks for the "Unable to retrieve AssociationType for association" workaround. I was stuck on that until I decided to read these  comments :-)<br /> ( apocalipstik) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Wed, 25 Mar 2009 15:07:52 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1275 <p>Hi, Bill!</p> <p> I assume that you have deleted the association and tried to add a new one. In order to map it, select the association line in the model diagram and right-click it, from the context menu select Table Mapping. In the bottom of your Visual Studio a Mapping Details window should appear.</p> <p><img alt="" src="http://www.silverlightshow.net/Storage/Users/Enrai/mapping-1.png" /></p> <p>This should do the work, but there is something else, that I forgot to mention in the article - it's about the association's name. When I left the default aspnet_Rolesaspnet_UsersInRoles name, I got an error "Unable to retrieve AssociationType for association 'aspnet_Rolesaspnet_UsersInRoles'". If you take a look at the other associations' names, you'll see that they have some wacky names. I created an empty model (which should be deleted afterwards) and added only the aspnet_Roles and aspnet_UsersInRoles tables. The association between them was generated automatically, so I took the name for my association from there. I know this some kind of strange workaround, but I am still new to the Entity Framework. It's also possible that this could be an issue between the two frameworks. If anyone can share some information about that, it would be nice. :)</p> <p> If you have more questions, Bill, just ask. </p> ( Enrai) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Wed, 25 Mar 2009 05:18:20 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1250 When I try to do the remapping of aspnet_Roles and aspnet_UsersInRoles, I get the error<br /> <br /> Error 11008: Association 'aspnet_Rolesaspnet_UsersInRoles' is not mapped.<br /> <br /> What did I miss? ( Bill) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Sun, 22 Mar 2009 09:34:25 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1233 Hi, Rob!<br /> <br /> Actually there is no need to add reference to the server project, as we do with the services for example. The DomainService class is available on the client thanks to the code, generated by the server in the GeneratedCode folder, that can be found in the client project. That is one of the main features of the .NET RIA Services Framework - it allows to create a link between the server and the client when we are creating our project. After that a specific parts of the server code, marked with specific attributes, or a specific files are generated on the client in the GeneratedCode folder. It's not included in the project so click on the "Show All Files" icon in order to see it. :)<br /> ( Enrai) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Fri, 20 Mar 2009 04:24:32 +0300 RE: Creating applications with .NET RIA Service Part 3 - Adding DomainService class http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx#comment1224 When opening the client you have, you have to remember to add a reference to the server in order to have access to DomainService Class.<br /> ( Rob Beasley) http://www.silverlightshow.net/items/Creating-applications-with-.NET-RIA-Service-Part-3-Adding-DomainService-class.aspx Thu, 19 Mar 2009 19:37:00 +0300